【问题标题】:FontAwesome webfont files giving error 404 (Not Found) on Windows Server running IIS 7.5FontAwesome webfont 文件在运行 IIS 7.5 的 Windows Server 上给出错误 404(未找到)
【发布时间】:2017-10-25 12:59:56
【问题描述】:

正在开发 MVC5 应用程序。像本地开发盒上的魅力一样工作。将文件复制到服务器并且与字体相关的东西不起作用。我在 Chrome 的开发工具中遇到这些错误...

fontawesome-webfont.woff2 Failed to load resource: 
       the server responded with a status of 404 (Not Found)
fontawesome-webfont.woff Failed to load resource: 
       the server responded with a status of 404 (Not Found)
fontawesome-webfont.ttf Failed to load resource: 
       the server responded with a status of 404 (Not Found)

是的,文件在服务器上。

服务器信息:Windows Server 2008 R2 Standard; IIS 7.5.7600.16385

经过大量研究,我在网上找到了几个关于将 MIME 行添加到 web.config 的解决方案。有几种变体,但它们似乎都不起作用。例如,对于 .woff,我尝试过...

<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />

还有

<mimeMap fileExtension=".woff" mimeType="application/font-woff" />

等等……

首先我删除了这些项目。比如……

<remove fileExtension=".woff" />

还有其他建议吗?屏幕截图将显示 Chrome 调试器 (404)、IIS MIME 条目和 web.config MIME 部分。

【问题讨论】:

  • 抱歉,移至下面的答案以使其更具可读性。

标签: asp.net-mvc iis iis-7.5 font-awesome mime


【解决方案1】:

这为我解决了这个问题:将以下内容放入您的 system.webServer 标签中:

<staticContent>
  <remove fileExtension=".woff" />
  <remove fileExtension=".woff2" />
  <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
  <mimeMap fileExtension=".woff2" mimeType="font/x-woff" />
</staticContent>

【讨论】:

  • 谢谢。我试过这个,但它仍然不起作用。在 Chrome 开发工具中,我可以看到 404 错误。例如 fontawesome-webfont.woff2 加载资源失败:服务器响应状态为 404 (Not Found)
猜你喜欢
  • 2016-01-06
  • 1970-01-01
  • 2012-11-04
  • 2011-08-29
  • 1970-01-01
  • 1970-01-01
  • 2013-03-14
  • 1970-01-01
  • 2015-10-18
相关资源
最近更新 更多