asp.net-mvc - FontAwesome webfont 文件在运行 IIS 7.5 的 Windows 服务器上出现错误 404(未找到)

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

正在处理 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 部分。

enter image description here

最佳答案

这为我解决了这个问题:将以下内容放入您的 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/

相关文章:

asp.net - IIS 自动启动未禁用空闲超时

IIS 客户端证书无效。返回 403 错误

http - 远程主机关闭了连接

c# - 在一台 Visual Studio 开发服务器中运行多个 Web 应用程序?

asp.net - MVC 应用程序中的 Aspx 母版页

powershell - 通过站点名称杀死IIS工作进程

asp.net - 由于 HttpModule 导致客户端缓存关闭?

.net - ..ActiveDirectory.ActiveDirectorySite.getComputerSite().name 返回错误 : ActiveDirectoryObjectNotFoundException

c# - SetCookie 似乎无法正常工作

c# - ASP.NET MVC : No parameterless constructor defined for this object