Html 如何解决 ASP.Net MVC 5 中的 glyphicons-halflings-regular.woff2 Err_Aborted 问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46508793/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 14:55:50  来源:igfitidea点击:

How to solve glyphicons-halflings-regular.woff2 Err_Aborted issue in ASP.Net MVC 5

htmlcssasp.net-mvctwitter-bootstrapbootswatch

提问by Unbreakable

So I have a project where I want to change the theme of BootStrap. So, I took theme from BootSwatchand the theme is selected is Lumen. Now in my Bundle.Config file, I made below changes.

所以我有一个项目,我想改变 BootStrap 的主题。所以,我从BootSwatch 中获取了主题,并且选择的主题是Lumen。现在在我的 Bundle.Config 文件中,我进行了以下更改。

  bundles.Add(new StyleBundle("~/Content/css").Include(
                      //"~/Content/bootstrap.css",
                      "~/Content/bootstrap-lumen.css",
                      "~/Content/superslides.css",
                      "~/Content/site.css"));
        }

Now as soon as I start using the Lumen Theme, I get error (in dev tool) as below: enter image description here

现在,一旦我开始使用 Lumen 主题,就会出现如下错误(在开发工具中): 在此处输入图片说明

P.S: This does nothappen when I use normal BootStraptheme. I looked into SO Answer. But it talks about making IIS changes and all. But my problem only occurswhen I use LUMENtheme. How to get rid of this issue?

PS:当我使用普通的 BootStrap主题时不会发生这种情况。我调查了SO Answer。但它谈到了对 IIS 的更改等等。但是我的问题在我使用LUMEN主题时出现。如何摆脱这个问题?

enter image description here

在此处输入图片说明

回答by Reyan Chougle

I have downloaded the missing files from hereand added those in fontsfolder of my project.

我已经从这里下载了丢失的文件并将它们添加fonts到我的项目文件夹中。

Then added these lines within <system.webServer>section in web.configfile of my project:

然后<system.webServer>web.config我的项目文件的部分中添加这些行:

<staticContent>
  <remove fileExtension=".woff" />
  <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
  <remove fileExtension=".woff2" />
  <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>

In your case, download glyphicons-halflings-regular.woff2file.

在您的情况下,下载glyphicons-halflings-regular.woff2文件。

回答by TylerBUrquhart

As an alternate to Reyan Chougle'sanswer, this can also be fixed through IIS:

作为Reyan Chougle答案的替代,这也可以通过 IIS 修复:

  1. Open IIS, click on your site.
  1. 打开IIS,点击你的站点。

Step 1

第1步

  1. In the middle section, under the grouping IIS, double-click MIME Types
  1. 在中间部分,在分组IIS 下,双击MIME Types

Step 2

第2步

  1. Edit or add woffand/or woff2extensions:
    • .woff -> application/x-font-woff
    • .woff2 -> application/font-woff2
  1. 编辑或添加woff和/或woff2扩展:
    • .woff -> 应用程序/x-font-woff
    • .woff2 -> 应用程序/font-woff2

Step 4

第四步

NOTE: Tested on IIS 8.5 in the Chrome web browser

注意:在 IIS 8.5 上在 Chrome 网络浏览器中测试

回答by Avinash

I was facing the same issue.

我面临着同样的问题。

In first attempt, I have added the MIME type (font-woff2) directly at the IIS server, it worked. However after deployment(CI/CD) MIME type automatically got removed.

在第一次尝试中,我直接在 IIS 服务器上添加了 MIME 类型 (font-woff2),它起作用了。但是在部署(CI/CD)后,MIME 类型自动被删除。

In Second attempt, I have added staticContent tags in web.config and it worked like a permanent fix.

在第二次尝试中,我在 web.config 中添加了 staticContent 标签,它就像一个永久修复程序。

回答by Jaider

I had a similar issue with WordPress. I had a folder on the root of the directory with a path to the font, and for some reason, I got net::ERR_ABORTEDand 404 (Not Found). So what I did was to move those fonts to wp-content/pluginswhere other fonts were defined such as FontAwesome... and it works!

我在WordPress 上遇到了类似的问题。我在目录的根目录上有一个文件夹,里面有字体的路径,出于某种原因,我得到了net::ERR_ABORTED404 (Not Found)。所以我所做的是将这些字体移动到wp-content/plugins定义其他字体的地方,例如 FontAwesome ......并且它起作用了!