部署后没有显示捆绑的CSS ... ASP.NET MVC4

Sco*_*lvi 9 asp.net-mvc bundling-and-minification

在部署我的MVC应用程序时,.NET 4.5框架正在捆绑和缩小我的CSS.但是,结果文件为空,因此不应用CSS规则.在Chrome中,我收到了Resource interpreted as Stylesheet but transferred with MIME type text/plain警告.在IE9中,我收到CSS was ignored due to mime type mismatch警告.

这就是我的BundleConfig中的内容

bundles.Add(
    new StyleBundle("~/Content/bootstrap").Include(
        "~/Content/bootstrap/bootstrap-responsive.css",
        "~/Content/bootstrap/bootstrap-editable.css",
        "~/Content/bootstrap/FileUpload.css"));
Run Code Online (Sandbox Code Playgroud)

这是我的布局头:

<head>
    <meta charset="utf-8" />
    <meta http-equiv="x-ua-compatible" content="IE=Edge" />
    <title>@ViewBag.Title</title>
    <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
    <meta name="viewport" content="width=device-width" />
    <link href="@ViewBag.StyleUrl" rel="stylesheet" type="text/css" />
    @Styles.Render("~/Content/bootstrap")
    <script src="~/scripts/libs/modernizr/modernizr-2.5.3.js" type="text/javascript"></script>
</head>
Run Code Online (Sandbox Code Playgroud)

额外的样式表用于基于管理工具中的配置的动态加载样式表.

当我在本地运行,或者如果我设置debug ="true",那么我得到我的个人文件和一切看起来应该.如果我将这些硬编码到我的布局页面,它们显示正常.我已经检查过IIS并查看了CSS的正确MIME类型(考虑到硬编码值的工作原理,这是有意义的).我还检查了以确保安装了"静态内容"角色服务,因为我在Google搜索中也遇到过这种情况.

有什么想法吗?

sto*_*boo 23

捆绑包名称与文件系统上的文件夹名称相同,

将您的包更改为

bundles.Add(
new StyleBundle("~/Content/bootstrapBundle").Include(
    "~/Content/bootstrap/bootstrap-responsive.css",
    "~/Content/bootstrap/bootstrap-editable.css",
    "~/Content/bootstrap/FileUpload.css"));
Run Code Online (Sandbox Code Playgroud)

即所以捆绑的名称不是文件夹或文件的名称

  • 要命!救了我的一天. (2认同)