尽管在IIS中设置了woff,ttf,svg和eot 404ing的MIME类型

use*_*400 19 fonts iis-7.5 woff mime-types eot

我试图让一个字体在一个文件中呈现,它给我通常的错误

Resource interpreted as Font but transferred with MIME type text/html:
Run Code Online (Sandbox Code Playgroud)

但是展示的HTML文件是我们的404.aspx文件,我尝试在web.config中安装应用程序,然后最终进入IIS本身:

.woff  application/font-woff
.ttf   application/font-ttf
.eot   application/vnd.ms-fontobject
.otf   application/font-otf
.svg   image/svg+xml
Run Code Online (Sandbox Code Playgroud)

我无法理解我哪里出错了.这些文件存储在一个名为fonts的文件夹中,该文件夹位于该站点的基本目录中,我的样式位于我的aspx文件中

@font-face {
    font-family: 'segoe_printregular';
    src: url('/fonts/segoepr-webfont.eot'); /* IE9 Compat Modes */
    src: url('/fonts/segoepr-webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
         url('/fonts/segoepr-webfont.woff') format('woff'), /* Modern Browsers */
         url('/fonts/segoepr-webfont.ttf')  format('truetype'), /* Safari, Android, iOS */
         url('/fonts/segoepr-webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
    font-weight: normal;
    font-style: normal;
}
Run Code Online (Sandbox Code Playgroud)

和fonts文件夹中的stylesheet.css如下:

@font-face {
    font-family: 'segoe_printregular';
    src: url('/segoepr-webfont.eot'); /* IE9 Compat Modes */
    src: url('/segoepr-webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
         url('/segoepr-webfont.woff') format('woff'), /* Modern Browsers */
         url('/segoepr-webfont.ttf')  format('truetype'), /* Safari, Android, iOS */
         url('/segoepr-webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
    font-weight: normal;
    font-style: normal;
    }
Run Code Online (Sandbox Code Playgroud)

我已经尝试将文件路径作为/ fonts /而字体/无效.但我无法将文件提交到404.有人建议重新启动服务器,但这也没有实现.

有什么我想念的吗?还是我犯了一些错误?

如果它有帮助我也在web.config中尝试过这个

<staticContent>
    <remove fileExtension=".woff" />
    <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
    <remove fileExtension=".ttf" />
    <mimeMap fileExtension=".ttf" mimeType="application/font-ttf" />
    <remove fileExtension=".eot" />
    <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
    <remove fileExtension=".otf" />
    <mimeMap fileExtension=".otf" mimeType="application/font-otf" />
    <remove fileExtension=".svg" />
    <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
</staticContent>
Run Code Online (Sandbox Code Playgroud)

Osa*_*a E 41

对于那些需要回答的人.以下是解决方案.参考http://www.alienfactory.co.uk/articles/mime-types-for-web-fonts-in-bedsheet了解详情.

<remove fileExtension=".woff" />
<remove fileExtension=".eot" />
<remove fileExtension=".ttf" />
<remove fileExtension=".svg" />

<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
<mimeMap fileExtension=".ttf" mimeType="application/font-sfnt" />
<mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
Run Code Online (Sandbox Code Playgroud)

  • 请注意,`font/woff2`只是*提案*并且尚未被互联网号码分配机构(IANA)接受 - 请参阅[字体顶级类型](https://datatracker.ietf.org/doc IETF网站上的/ draft-ietf-justfont-toplevel /)跟踪器. (3认同)
  • 对于.woff2文件:`<mimeMap fileExtension =".woff2"mimeType ="font/woff2"/>`请参阅https://www.w3.org/TR/WOFF2/#IMT (2认同)