如何在Web.config中正确添加字体Mime映射
本文关键字:添加 字体 Mime 映射 Web config | 更新日期: 2023-09-27 18:16:22
其他帖子建议我添加
<mimeMap fileExtension=".woff" mimeType="application/x-woff" />
或
<mimeMap fileExtension=".woff" mimeType="application/woff" />
为font-awesome
图标。
但是在我有
之后<system.webServer>
<staticContent>
<mimeMap fileExtension=".woff" mimeType="application/woff" />
</staticContent>
</system.webServer>
我发现所有其他静态资源都无法加载。我的浏览器控制台指出,.js
, .css
, .png
等的所有GET
都以500内部服务器错误结束。
那么我怎么能只添加一个mime类型而不删除所有其他现有的mime映射?
刚刚找到解决办法了。
由于我们不能有重复的mimemap,我需要添加一个remove。
<system.webServer>
<staticContent>
<remove fileExtension=".woff"/>
<mimeMap fileExtension=".woff" mimeType="application/woff" />
</staticContent>
</system.webServer>
我发现application/woff
和application/x-woff
都可以工作。
这对我来说很好。
<staticContent>
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
</staticContent>