正在处理 MVC5 应用程序。在本地开发箱上就像一个魅力。将文件复制到服务器,与 fontawesome 相关的东西不起作用。我在 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" />
还有其他建议吗?屏幕截图将显示 Chromes 调试器 (404),还有 IIS MIME 条目和 web.config MIME 部分。
最佳答案
这为我解决了这个问题:将以下内容放入您的 system.webServer 标签中:
<staticContent>
<remove fileExtension=".woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
<mimeMap fileExtension=".woff2" mimeType="font/x-woff" />
</staticContent>
关于asp.net-mvc - FontAwesome webfont 文件在运行 IIS 7.5 的 Windows 服务器上出现错误 404(未找到),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44170978/