gpt4 book ai didi

asp.net-mvc - 部署后不显示捆绑的 css ... ASP.NET MVC4

转载 作者:行者123 更新时间:2023-12-03 23:06:45 24 4
gpt4 key购买 nike

在部署我的 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"));

这是我的布局头:
<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>

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

当我在本地运行它时,或者如果我设置了 debug="true",那么我会得到我的个人文件 & 一切看起来都应该如此。如果我将这些硬编码到我的布局页面中,它们显示良好。我已经检查了 IIS 并查看了 CSS 的正确 MIME 类型(鉴于硬编码值有效,这是有道理的)。我还检查过以确保安装了“静态内容”角色服务,因为我在谷歌搜索中也遇到了这个问题。

有什么想法吗?

最佳答案

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

将您的捆绑包更改为

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

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

关于asp.net-mvc - 部署后不显示捆绑的 css ... ASP.NET MVC4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14969420/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com