简体   繁体   English

为什么 JavaScript 在现有虚拟目录下无法在我的网站上运行?

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

I deployed my ASP.NET application under an existing virtual directory.我在现有的虚拟目录下部署了我的 ASP.NET 应用程序。 The new deployment will have some features using JavaScript. The new features are not working.新部署将有一些使用 JavaScript 的功能。新功能不起作用。

If I deploy this build under a new virtual directory, the features using JavaScript are working.如果我在新的虚拟目录下部署此构建,则使用 JavaScript 的功能正在运行。

I restarted the IIS Admin service.我重新启动了 IIS 管理服务。 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.由于 javascript 在客户端而不是服务器上运行,我怀疑 IIS 本身与您的问题有任何关系。

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)?是否开启了任何调试工具(例如Firebug 或IE8 中的F12 命令)? 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?调用Javascript例程的代码是动态生成的吗? 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.比如ASP.NET,应该用“~”来表示应用程序的当前路径。 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检查IIS Manager上的 IIS APPLICATION POOL 和Visual Studio上的项目 Target Framework

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?尝试更改 JavaScript 文件的 src?

From this:由此:

To this:对此:

This method should force your browser to load a new copy of the JS file.此方法应强制您的浏览器加载 JS 文件的新副本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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