当我尝试将ASP应用程序部署到IIS时,我遇到了一些严重的脚本和样式问题。
我正在做的是:首先我使用visual studio发布我的应用程序然后在IIS上我点击一个网站然后部署然后导入一个应用程序
该网站正在按预期工作,我可以使用指定的端口和URL访问它,但我正在丢失我的CSS,javascript和jQuery。
一些事实:
我在我的Web.config中将debug设置为false:<compilation debug="false" targetFramework="4.0" />
我从NuGet安装 Microsoft ASP.NET Web Optimization 到我的应用
当使用萤火虫或镀铬金丝雀来检查发生的事情时,我可以看到如下链接: href =“/ Content / css / bootstrap.min.css”等... 当我改变它 href =“Content / css / bootstrap.min.css”
即只需将“/ Content”更改为“Content”即可使所有内容按预期工作
任何想法? !
答案 0 :(得分:0)
见MVC 4 Bundle - unable to bundle content e.g. css/javascript outside MVC project content folder。您可以使用“CDN路径”添加捆绑包,在该路径中将正确的URL放入捆绑包中:
string cdnPath = "http://yourserver/yourpath/Content/foo.js";
bundles.Add(new ScriptBundle("~/bundles/jquery", cdnPath).Include(
或接受MVC Bundling and CSS relative URLs的建议:
不要在带有路径的CSS上使用捆绑,因为除非在非常简单的情况下它被破坏。直接链接缩小的CSS要容易得多。