Contact us


All times are UTC - 8 hours



   [ 5 posts ] 
Author Message
   


Joined: Wed Oct 18, 2017 11:35 am
Posts: 4
how do we go about updating where the scripts look for referenced js files? For example, I'm getting a 404 error because the script is looking for the dynamsoft.webtwain.install.js file.
This is an MVC site and it's looking for the resources folder under the view.


User avatar
   


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1706
Hi Mpackard,

Thanks for contacting Dynamsoft.

As you may know, MVC is different from other regular web applications. The way how resources are referenced is also different.

To add a new scan page in your MVC project, please refer to the following steps.

Firstly, please try the followings in your BundleConfig.cs to reference the JS files.

bundles.Add(new ScriptBundle("~/Resources/dynamsoft.webtwain").Include(
"~/Resources/dynamsoft.webtwain.config.js",
"~/Resources/dynamsoft.webtwain.initiate.js"));
bundles.Add(new ScriptBundle("~/Scripts/dynamsoft.webtwain").Include(
"~/Scripts/{your own JS code}.js"));


Secondly, in the _Layout.cshtml, the <HEAD/> tag, add the scripts like this:

@Scripts.Render("~/Resources/dynamsoft.webtwain")
@Scripts.Render("~/Scripts/dynamsoft.webtwain")

Last but not the least, kindly open dynamsoft.webtwain.config.js in the Resources folder, and update like followings.

Dynamsoft.WebTwainEnv.ResourcesPath = '../Resources';

In result, the TWAIN control on your scan page (e.g. View -> Home -> Scan.cshtml) will get the resources successfully.

<div id="dwtcontrolContainer" style="float: left;"></div>
<input type="button" value="Scan" onclick="AcquireImage();" />

Please try and let me know how it works.

Regards,

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


   


Joined: Wed Oct 18, 2017 11:35 am
Posts: 4
I've bundled the initiate, config and my js file, they seem to be working fine.

bundles.Add(new ScriptBundle("~/bundles/scanner")
.Include("~/Scripts/Resources/dynamsoft.webtwain.initiate.js")
.Include("~/Scripts/Resources/dynamsoft.webtwain.config.js")
.Include("~/Scripts/scanning.js"));


The files that are giving me issues right now are:
dynamsoft.webtwain.install.js?t=20170607
dynamsoft_dwt_html5.css?t=20170607
loading.gif


the only one that really concerns me is the install.js as I'm pretty sure without that my users won't be prompted to install the plugin. the other two files I might end up overriding anyways. I have the REsources folder located in my scripts folder on the main trunk of the site. should I include the install file in my bundle?


User avatar
   


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1706
Hi Mpackard,

Thanks for getting back to me.

Could you download this sample to see if you can reproduce the issue?

Regards,

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


   


Joined: Wed Oct 18, 2017 11:35 am
Posts: 4
After looking closer at the example I added the following code to the dynamsoft.webtwain.config.js file:

Code:
(function () {
    var p = document.location.protocol;
    if (p !== 'https:' && p !== 'http:')
        Dynamsoft.WebTwainEnv.ResourcesPath = "../Scripts/Resources";
    else
        Dynamsoft.WebTwainEnv.ResourcesPath = "../Scripts/Resources";
})();



now I'm seeing GET http://localhost:49689/TextDocuments/Sc ... t=20170607 net::ERR_ABORTED


Here's the whole log file
Code:
jquery-migrate-1.2.1.js:21 JQMIGRATE: Logging is active
dynamsoft.webtwain.initiate.js:13 GET http://localhost:49689/TextDocuments/Scripts/Resources/dynamsoft.webtwain.install.js?t=20170607 net::ERR_ABORTED
lib.getScript @ dynamsoft.webtwain.initiate.js:13
(anonymous) @ dynamsoft.webtwain.initiate.js:17
setTimeout (async)
R @ dynamsoft.webtwain.initiate.js:17
(anonymous) @ dynamsoft.webtwain.initiate.js:17
fireReady @ dynamsoft.webtwain.initiate.js:13
domReady @ dynamsoft.webtwain.initiate.js:13
dynamsoft.webtwain.initiate.js:13 GET http://localhost:49689/TextDocuments/Scripts/Resources/reference/dynamsoft_dwt_html5.css?t=20170607 net::ERR_ABORTED
lib.getCss @ dynamsoft.webtwain.initiate.js:13
(anonymous) @ dynamsoft.webtwain.initiate.js:17
loading.gif:1 GET http://localhost:49689/TextDocuments/Scripts/Resources/reference/loading.gif 404 (Not Found)
Image (async)
a.detect.OnWebTwainPreExecute @ dynamsoft.webtwain.initiate.js:14
a.detect.showMask @ dynamsoft.webtwain.initiate.js:14
K @ dynamsoft.webtwain.initiate.js:17
O @ dynamsoft.webtwain.initiate.js:17
Z @ dynamsoft.webtwain.initiate.js:17
loading.gif:1 GET http://localhost:49689/TextDocuments/Scripts/Resources/reference/loading.gif 404 (Not Found)
Image (async)
a.detect.OnWebTwainPreExecute @ dynamsoft.webtwain.initiate.js:14
a.detect.showMask @ dynamsoft.webtwain.initiate.js:14
a.startWS @ dynamsoft.webtwain.initiate.js:16
(anonymous) @ dynamsoft.webtwain.initiate.js:17
setTimeout (async)
b @ dynamsoft.webtwain.initiate.js:17
e @ dynamsoft.webtwain.initiate.js:17
(anonymous) @ dynamsoft.webtwain.initiate.js:17
(anonymous) @ dynamsoft.webtwain.initiate.js:17
setTimeout (async)
T @ dynamsoft.webtwain.initiate.js:17
_ioReady @ dynamsoft.webtwain.initiate.js:13
_callback @ dynamsoft.webtwain.initiate.js:13
T.onreadystatechange @ dynamsoft.webtwain.initiate.js:13
XMLHttpRequest.send (async)
(anonymous) @ VM1940:1
sendInternal @ dynamsoft.webtwain.initiate.js:13
q @ dynamsoft.webtwain.initiate.js:13
q @ dynamsoft.webtwain.initiate.js:13
U @ dynamsoft.webtwain.initiate.js:17
versionInfo @ dynamsoft.webtwain.initiate.js:17
r @ dynamsoft.webtwain.initiate.js:17
(anonymous) @ dynamsoft.webtwain.initiate.js:17
setTimeout (async)
f @ dynamsoft.webtwain.initiate.js:13
_ioReady @ dynamsoft.webtwain.initiate.js:13
_callback @ dynamsoft.webtwain.initiate.js:13
T.onreadystatechange @ dynamsoft.webtwain.initiate.js:13
XMLHttpRequest.send (async)
(anonymous) @ VM1940:1
sendInternal @ dynamsoft.webtwain.initiate.js:13
q @ dynamsoft.webtwain.initiate.js:13
q @ dynamsoft.webtwain.initiate.js:13
g @ dynamsoft.webtwain.initiate.js:13
versionInfo @ dynamsoft.webtwain.initiate.js:13
K @ dynamsoft.webtwain.initiate.js:17
O @ dynamsoft.webtwain.initiate.js:17
Z @ dynamsoft.webtwain.initiate.js:17
dynamsoft.webtwain.initiate.js:13 [Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.
sendInternal @ dynamsoft.webtwain.initiate.js:13
q @ dynamsoft.webtwain.initiate.js:13
b._innerFunRaw @ dynamsoft.webtwain.initiate.js:16
b._innerFun @ dynamsoft.webtwain.initiate.js:16
set @ dynamsoft.webtwain.initiate.js:16
(anonymous) @ dynamsoft.webtwain.initiate.js:16
d.onmessage @ dynamsoft.webtwain.initiate.js:16


Display posts from previous:  Sort by  
   [ 5 posts ] 


Who is online

Users browsing this forum: WillieCam and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Copyright © 2018 Dynamsoft | All Rights Reserved
dynamic designed by Dynamsoft team
Fatal: Not able to open ./cache/data_global.php