简体   繁体   English

发布到我的服务器时无法加载外部javascript文件

[英]external javascript files not loading when published to my server

My ASP.NET MVC app uses some external javascript and jquery files. 我的ASP.NET MVC应用程序使用一些外部javascript和jquery文件。 Everything works just fine on my dev machine. 在我的开发机上一切正常。 As soon as I post it to my server none of the .js files even load. 一旦将其发布到服务器上,就不会加载任何.js文件。 I have used Url.Content() as well as an app helper with the same result. 我使用了Url.Content()以及具有相同结果的应用程序帮助程序。 They work fine on the dev machine but don't even load on when published to the server. 它们在开发机器上可以正常工作,但是在发布到服务器上时甚至不加载。 I am really at a wall and have no idea what this could be. 我真的在墙上,不知道这可能是什么。 Any ideas what I could try next? 有什么想法我接下来可以尝试吗? Thanks 谢谢

I have tried 我努力了

<script src="../../Scripts/SiteMaster.js" type="text/javascript"></script>

as well as 以及

<script src='<%=Url.Content("~/Scripts/SiteMaster.js") %>' type="text/javascript"></script>

both work on the dev machine neither work on the server. 两者都可以在开发机器上工作,也不能在服务器上工作。

ResolveUrl should be all you need ResolveUrl应该是您所需要的

<script 
    src="<%=ResolveUrl("~/Scripts/SiteMaster.js") %>" 
    type="text/javascript"></script>

also make sure you've added this IgnoreRoute: 还请确保您已添加以下IgnoreRoute:

routes.IgnoreRoute("scripts/{*pathInfo}");

I found the Issue!!! 我发现了问题!!! my other programmer created a virtual directory (for some reason) named "scripts" in IIS and had it pointed at a different location on the file system. 我的另一个程序员在IIS中创建了一个名为“脚本”的虚拟目录(由于某种原因),并使其指向文件系统上的其他位置。 I appreciate all your help with this! 感谢您的协助! I have fixed it. 我已经解决了。 Thanks Again! 再次感谢!

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

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