CSS捆绑在asp.net mvc4应用程序中不起作用

时间:2013-07-22 21:14:35

标签: asp.net-mvc-4 bundling-and-minification

我的BundleConfig.cs文件中有以下内容

bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/reset.css",
"~/Content/site.css"));

在我的_Layout.cshtml文件中,我设置了这样的样式

@Styles.Render("~/Content/css")

当我在web.config文件中将debug设置为false时,我会在html源代码中找到它

<link rel="stylesheet" href="/Content/css?v=o98MVeaPnTOPDtb6WAqw14YyALxEnOYDmGqwfyBAiq01">
The resource from this url is not text: http://localhost:1135/Content/css?v=o98MVeaPnTOPDtb6WAqw14YyALxEnOYDmGqwfyBAiq01
</link>

并没有应用任何样式。我在这里缺少什么?

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,发现这是一个权限问题。为了在运行时创建包文件确保IUSR已读取&amp;对目录执行权限。我不使用Cassini来调试我的VS项目,而是在IIS中创建应用程序。我这样做是通过将它们添加到我的主机文件中,如127.0.0.1 mysitename.local,然后使用域名mysitename.local创建一个IIS应用程序(我使用.local域扩展名以确保不会与真实版本冲突) TLD)并在VS项目属性中进行设置。这样做会发生IIS继承父对象的权限(在我的情况下为C:\ workspace),因此默认情况下不包含IUSR。