html - IE 和 Edge 的网站 CSS 加载问题

标签 html css asp.net-mvc internet-explorer

我的网站在 Chrome、Firefox、Safari 等平台上运行良好。但是,CSS 无法在 Internet Explorer(任何版本)和 MS Edge 浏览器中加载。

控制台显示与 MIME 类型相关的臭名昭著的错误:

SEC7113: CSS was ignored due to mime type mismatch
File: application-2015-2a0565839ee60a029c49fc918e3625e9.css
SEC7113: CSS was ignored due to mime type mismatch
File: CustomCss.css
SEC7113: CSS was ignored due to mime type mismatch
File: print.css

我已经检查了代码,这就是它在 <head> 中的样子

// ASP.NET MVC code - .cshtml layout file
<link href='@Url.Content("/Content/application-2015-2a0565839ee60a029c49fc918e3625e9.css")' media="screen" rel="stylesheet" type="text/css"/>
<link href='@Url.Content("/Content/CustomCss.css")' media="screen" rel="stylesheet" type="text/css"/>
<link href='@Url.Content("/Content/2015/print.css")' media="print" rel="stylesheet" type="text/css"/>

我检查了 IE 开发人员工具,在 IE 中确实返回了不正确的 MIME 类型(显示为空白)的 css,而不是 Chrome 或 Firefox 中的样式表或文本/css:

IE: enter image description here

Chrome : enter image description here

我已经在 IIS 中检查过,.css 的 mime 类型按预期映射: enter image description here

如何让 IE 理解 Mime 类型并让它正确加载。

非常感谢任何帮助。

编辑

按照建议,还检查了 HKEY_CLASSES_ROOT 中 .css 的注册表值,这似乎没问题,如下所示: enter image description here

另外,确保没有程序与要打开的 CSS 关联。

最佳答案

这是因为在默认设置下,“静态内容”没有随 IIS 安装。

要在 Windows Server 2008 机器上启用此功能,请执行以下操作

  1. 启动服务器管理器

  2. 在 Roles 下选择 Web Server——注意没有安装 Static Content

enter image description here

从右侧菜单中选择添加 Angular 色服务

enter image description here

检查静态内容并安装

我认为它适合你

关于html - IE 和 Edge 的网站 CSS 加载问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41347104/

相关文章:

html - 嵌套跨度上未禁用 CSS 直通

c# - 如果条件为假,则 Razor 添加类

javascript - 使用现有 SVG 路径遮盖图像

asp.net-mvc - 在 ASP.NET MVC 5 中使用 Entity Framework 中的存储过程从多个表中获取多条记录

c# - ASP.NET MVC View 内部 View

c# - 对象引用未设置到对象的实例: Yelp Return Values

javascript - 如何将最大高度 css 属性指定为屏幕尺寸

html - 段落不会使用 css 命令居中

javascript - 基于切换时删除/添加类

javascript - 在javascript中访问外部CSS文件的ID