简体   繁体   中英

Why does JavaScript not work on my site under an existing virtual directory?

I deployed my ASP.NET application under an existing virtual directory. The new deployment will have some features using JavaScript. The new features are not working.

If I deploy this build under a new virtual directory, the features using JavaScript are working.

I restarted the IIS Admin service. The problem continues.

What could be going wrong here?

Since javascript runs on the client, and not on the server, I doubt that IIS, per se, has anything to do with your problem.

What have you done to attempt to diagnose the problem? Have you looked at the.network interaction between the browser and the server? Perhaps some script files are not being found.

Have you turned on any debugging tools (for instance, Firebug or the F12 command in IE8)? You may be getting errors you don't know about.

Sounds like it could be a caching issue on the browser.

Is the code that calls the Javascript routines being generated dynamically? If so, it might be a path assumption. Your description was a big vague. For instance, in ASP.NET, you should use "~" to represent the applications current path. This might change. If you have code that just referrs to "/" or another (perhaps the second attempted path), then perhaps it's just a bad assumption? Please provide more specifics. There are a hundred possible scenarios that fit your description.

Check the IIS APPLICATION POOL on IIS Manager and the project Target Framework on Visual Studio

try to match it

After the deployment if javascript features are not working then it may be beacuse executes the script which already cached. In this case to handle the situation please do the following

Try changing the JavaScript file's src?

From this:

To this:

This method should force your browser to load a new copy of the JS file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM