woff2、woff 和 ttf 文件未加载并给出 400 错误 [英] woff2, woff and ttf files not loaded and gave 400 error

查看:55
本文介绍了woff2、woff 和 ttf 文件未加载并给出 400 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么 woff2、woff 和 ttf 文件没有加载,但它们存在于assets"文件夹中?请推荐!

解决方案

问题是没有为您的 IISExpress 实例设置这些 MIME 类型.最初在此处找到的答案.>

答案 1:这将修复所有创建的站点的错误,这些站点将这些文件类型作为其解决方案的一部分并且正在耗尽 IISExpress.

部分引用:

打开位于 C:\Users\\Documents\IISExpress\config

中的 ApplicationHost.config

找到 staticContent 部分并在结束标记前附加以下几行:<代码><mimeMap fileExtension=".woff" mimeType="application/font-woff"/><mimeMap fileExtension=".woff2" mimeType="application/font-woff"/><mimeMap fileExtension=".ttf" mimeType="application/octet-stream/>

答案 1:这将修复该特定站点的错误,但是您创建的任何其他站点将这些文件类型作为其解决方案的一部分并且正在用完 IISExpress 都会遇到同样的问题.

为您的项目更新 Web.config.添加<代码><mimeMap fileExtension=".woff" mimeType="application/font-woff"/><mimeMap fileExtension=".woff2" mimeType="application/font-woff"/><mimeMap fileExtension=".ttf" mimeType="application/octet-stream/>在 configurationsystem.webServerstaticContent 部分.

这应该会让那些烦人的错误消失!

Why woff2, woff and ttf files are not loaded, however they are exist in "assets" folder? Please suggest!

解决方案

The problem is that those mime types aren't set for your IISExpress instance. Answer originally found here.

Answer 1: This will fix the error for all sites that create that have these file types as a part of their solution and are being run out of IISExpress.

Quoted in part:

Open ApplicationHost.config located in C:\Users\<user>\Documents\IISExpress\config

Locate staticContent section and append the following lines before the closing tag: <mimeMap fileExtension=".woff" mimeType="application/font-woff" /> <mimeMap fileExtension=".woff2" mimeType="application/font-woff" /> <mimeMap fileExtension=".ttf" mimeType="application/octet-stream />

Answer 1: This will fix the error for that particular site, but any others that you create that have these file types as a part of their solution and are being run out of IISExpress will encounter this same issue.

Update the Web.config for your project. Add <mimeMap fileExtension=".woff" mimeType="application/font-woff" /> <mimeMap fileExtension=".woff2" mimeType="application/font-woff" /> <mimeMap fileExtension=".ttf" mimeType="application/octet-stream /> in the staticContent section in system.webServer in configuration.

This should get those annoying errors to go away!

这篇关于woff2、woff 和 ttf 文件未加载并给出 400 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆