【问题标题】:Asp and IIS issuesASP 和 IIS 问题
【发布时间】:2014-03-12 05:46:43
【问题描述】:

当我尝试将 ASP 应用程序部署到 IIS 时,我遇到了一些严重的脚本和样式问题。

我正在做的是:首先我使用 Visual Studio 发布我的应用程序,然后在 IIS 上单击网站,然后部署并导入应用程序

该站点按预期运行,我可以使用指定的端口和 URL 访问它,但我的 css、javascript 和 jQuery 丢失了。

一些事实:

  1. 我在我的 Web.config 中将 debug 设置为 false:<compilation debug="false" targetFramework="4.0" />

  2. 我将 Microsoft ASP.NET Web Optimization 从 NuGet 安装到我的应用程序

  3. 当使用 firebug 或 chrome canary 检查发生的事情时,我可以看到如下链接: href="/Content/css/bootstrap.min.css" 等... 当我将其更改为 href="内容/css/bootstrap.min.css"

即只需将“/Content”更改为“Content”即可使一切按预期工作

有什么想法吗? !

【问题讨论】:

  • 您的应用程序是在网站的根目录中(例如http://servername),还是在子路径中(http://servername/MyApplication/)?

标签: c# html asp.net iis


【解决方案1】:

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 要容易得多。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-05-06
    • 1970-01-01
    • 1970-01-01
    • 2015-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多