发布的网站发布到Web服务器后,引导程序的Glyphicons没有显示 [英] Glyphicons of bootstrap not showing up after published site to the web server

查看:55
本文介绍了发布的网站发布到Web服务器后,引导程序的Glyphicons没有显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

When I run my MCV 5 app locally, these Glyphicons work fine. However, after I publish my site to the web server, these glyphicons don't show on the published site.

Below is in my bundleConfig.cs:

bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/font-awesome.css",
"~/fonts/glyphicons-*",
"~/Content/site.css"));

BundleTable.EnableOptimizations = false;

Below is the default font setting of Bootstrap.css version 3.3.7:

@font-face {
font-family: 'Glyphicons Halflings';

src: url('../fonts/glyphicons-halflings-regular.eot');
src: url('../fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('../fonts/glyphicons-halflings-regular.woff2') format('woff2'), url('../fonts/glyphicons-halflings-regular.woff') format('woff'), url('../fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg');
}

Does anyone know how I can fix this? The fonts folder is at the root level. Note: I am not using the "min" .css or .js version.





谢谢。



我尝试过:



我试过将fonts文件夹路径移到内容文件夹,但没有解决问题。建议好吗?谢谢。



Thank you.

What I have tried:

I have tried moving the fonts folder path to the "Content" folder but that didn't solve the problem. Suggestions please? Thank you.

推荐答案

首先,从你的包中删除〜/ fonts / glyphicons - *行配置。这将尝试将字体文件的原始字节渲染为CSS,这将无法工作。



最可能的问题是IIS不知道MIME类型用于字体文件。出于安全原因,IIS不会提供任何不知道MIME类型的文件。



要修复它,请添加 web。使用以下内容将文件添加到您的fonts文件夹:

Firstly, remove the "~/fonts/glyphicons-*" line from your bundle config. This will try to render the raw bytes of the font files as CSS, which will not work.

The most likely problem is that IIS doesn't know the MIME type for the font files. For security reasons, IIS will not serve any file where it doesn't know the MIME type.

To fix it, add a web.config file to your fonts folder with the following content:
<configuration>
    <system.webServer>
        <staticContent>
            <mimeMap fileExtension="eot" mimeType="application/vnd.ms-fontobject" />
            <mimeMap fileExtension="otf" mimeType="application/x-font-opentype" />
            <mimeMap fileExtension="svg" mimeType="image/svg+xml" />
            <mimeMap fileExtension="ttf" mimeType="application/x-font-truetype" />
            <mimeMap fileExtension="woff" mimeType="application/font-woff" />
            <mimeMap fileExtension="woff2" mimeType="application/font-woff2" />
        </staticContent>
    </system.webServer>
</configuration>

如果其他人遇到同样的问题,系统管理员会通过向IIS管理器添加文件类型来修复它。
In case anyone else has the same problem, the system admin fixed it by adding file types to the IIS manager.


这篇关于发布的网站发布到Web服务器后,引导程序的Glyphicons没有显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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