Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/259.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# IIS Web字体、引导3字形未使用IE9或10加载。Chrome和Firefox都可以工作_C#_Asp.net_Asp.net Mvc_Asp.net Mvc 4_Twitter Bootstrap - Fatal编程技术网

C# IIS Web字体、引导3字形未使用IE9或10加载。Chrome和Firefox都可以工作

C# IIS Web字体、引导3字形未使用IE9或10加载。Chrome和Firefox都可以工作,c#,asp.net,asp.net-mvc,asp.net-mvc-4,twitter-bootstrap,C#,Asp.net,Asp.net Mvc,Asp.net Mvc 4,Twitter Bootstrap,场景: @font-face { font-family: 'chunkfiveroman'; src: url('../Content/fonts/chunkfive-webfont.eot'); src: url('../Content/fonts/chunkfive-webfont.eot?#iefix') format('embedded-opentype'), url('../Content/fonts/chunkfive-webfont

场景:

@font-face {
    font-family: 'chunkfiveroman';
    src: url('../Content/fonts/chunkfive-webfont.eot');
    src: url('../Content/fonts/chunkfive-webfont.eot?#iefix') format('embedded-opentype'),
            url('../Content/fonts/chunkfive-webfont.woff') format('woff'),
            url('../Content/fonts/chunkfive-webfont.ttf') format('truetype'),
            url('../Content/fonts/chunkfive-webfont.svg#chunkfiveroman') format('svg'),
            url('../Content/fonts/Chunkfive.otf');
    font-weight: normal;
    font-style: normal;
}
将IIS 7.5与MVC4应用程序一起使用

如果浏览到字体的绝对路径,则可以从服务器下载字体。任何字体上都没有404错误

控制台中未显示其他错误,IE开发工具(或Chrome或Firefox开发工具)中未显示网络捕获错误

IE9和IE10-网页字体不加载。引导3字形图标不加载

Firefox和Chrome-Web字体加载正确。引导3字形图标正确加载

从Visual Studio 2012 dev服务器本地运行站点时,字体在所有浏览器中都能正常加载。引导图示符在所有浏览器中正确加载

我的CSS代码:

@font-face {
    font-family: 'chunkfiveroman';
    src: url('../Content/fonts/chunkfive-webfont.eot');
    src: url('../Content/fonts/chunkfive-webfont.eot?#iefix') format('embedded-opentype'),
            url('../Content/fonts/chunkfive-webfont.woff') format('woff'),
            url('../Content/fonts/chunkfive-webfont.ttf') format('truetype'),
            url('../Content/fonts/chunkfive-webfont.svg#chunkfiveroman') format('svg'),
            url('../Content/fonts/Chunkfive.otf');
    font-weight: normal;
    font-style: normal;
}
我尝试过的:

@font-face {
    font-family: 'chunkfiveroman';
    src: url('../Content/fonts/chunkfive-webfont.eot');
    src: url('../Content/fonts/chunkfive-webfont.eot?#iefix') format('embedded-opentype'),
            url('../Content/fonts/chunkfive-webfont.woff') format('woff'),
            url('../Content/fonts/chunkfive-webfont.ttf') format('truetype'),
            url('../Content/fonts/chunkfive-webfont.svg#chunkfiveroman') format('svg'),
            url('../Content/fonts/Chunkfive.otf');
    font-weight: normal;
    font-style: normal;
}
我已经为web字体(.otf、.eot、.woff)手动将mime类型添加到服务器中(.svg和.ttf已经存在)

我尝试过在所有手动添加的字体条目上设置mime类型,基于谷歌搜索(应用程序/八位字节流、字体/otf等)有很多不同的方式

我的求救请求:

@font-face {
    font-family: 'chunkfiveroman';
    src: url('../Content/fonts/chunkfive-webfont.eot');
    src: url('../Content/fonts/chunkfive-webfont.eot?#iefix') format('embedded-opentype'),
            url('../Content/fonts/chunkfive-webfont.woff') format('woff'),
            url('../Content/fonts/chunkfive-webfont.ttf') format('truetype'),
            url('../Content/fonts/chunkfive-webfont.svg#chunkfiveroman') format('svg'),
            url('../Content/fonts/Chunkfive.otf');
    font-weight: normal;
    font-style: normal;
}
还可能是什么?还有什么我可以试试的吗编辑:请参见下面的。如何让IE从服务器下载字体?同样,在Firefox和Chrome中,他们都下载了字体,效果很好

编辑:

@font-face {
    font-family: 'chunkfiveroman';
    src: url('../Content/fonts/chunkfive-webfont.eot');
    src: url('../Content/fonts/chunkfive-webfont.eot?#iefix') format('embedded-opentype'),
            url('../Content/fonts/chunkfive-webfont.woff') format('woff'),
            url('../Content/fonts/chunkfive-webfont.ttf') format('truetype'),
            url('../Content/fonts/chunkfive-webfont.svg#chunkfiveroman') format('svg'),
            url('../Content/fonts/Chunkfive.otf');
    font-weight: normal;
    font-style: normal;
}
你可以在本地看到,它下载了字体,效果很好


然而,当上传到服务器上的IIS时,它甚至没有尝试下载字体。

我遇到了这个问题,我发现这是由于在发布模式下构建时的缩小造成的

我没有从引导站点手动下载文件并配置绑定,而是使用nuget软件包来完成这项工作

如果您想这样做,请执行以下步骤

运行以下命令以安装引导程序:

Install-Package Twitter.Bootstrap.MVC
这将下载所有引导程序包文件,并包括以下预定义的引导程序包配置:

public class BootstrapBundleConfig
{
    public static void RegisterBundles()
    {
        // Add @Styles.Render("~/Content/bootstrap") in the <head/> of your _Layout.cshtml view
        // For Bootstrap theme add @Styles.Render("~/Content/bootstrap-theme") in the <head/> of your _Layout.cshtml view
        // Add @Scripts.Render("~/bundles/bootstrap") after jQuery in your _Layout.cshtml view
        // When <compilation debug="true" />, MVC4 will render the full readable version. When set to <compilation debug="false" />, the minified version will be rendered automatically
        BundleTable.Bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include("~/Scripts/bootstrap.js"));
        BundleTable.Bundles.Add(new StyleBundle("~/Content/bootstrap").Include("~/Content/bootstrap.css"));
        BundleTable.Bundles.Add(new StyleBundle("~/Content/bootstrap-theme").Include("~/Content/bootstrap-theme.css"));
    }
}
公共类BootstrapBundleConfig
{
公共静态无效注册表绑定()
{
//在您的_Layout.cshtml视图中添加@Styles.Render(“~/Content/bootstrap”)
//对于引导主题,在_Layout.cshtml视图的中添加@Styles.Render(“~/Content/Bootstrap theme”)
//在_Layout.cshtml视图中的jQuery之后添加@Scripts.Render(“~/bundles/bootstrap”)
//当设置为时,MVC4将呈现完全可读的版本。当设置为时,将自动呈现缩小的版本
添加(新脚本包(“~/Bundles/bootstrap”)。包括(“~/Scripts/bootstrap.js”);
添加(新样式包(“~/Content/bootstrap”)。包括(“~/Content/bootstrap.css”);
添加(新样式包(“~/Content/bootstrap主题”)。包括(“~/Content/bootstrap主题.css”);
}
}
上面还包括描述如何呈现捆绑包的注释

我认为最初的404字体错误是由于字体文件夹处于与缩小css中指定的不同的级别

如果您希望保留当前的解决方案,那么我修复404的唯一方法就是将字体文件夹复制到web应用程序的根目录,并保留字体的默认引导css


要在本地测试它,只需从web配置中删除
debug=“true”

在这方面花了很多时间之后,我通过使用浏览器检测Javascript解决了这个问题。一旦我准备好了这个,我就去透明的PNG中寻找我需要在特定字体/字形中渲染的文本和字形

编辑:2016年1月

问题解决了。问题的根源在于IE安全设置。在internet选项中,将服务器的域/IP地址设置更改为中等或以上,并确保禁用“受保护模式”


此外,如果您通过服务器的FQDN而不是IP访问服务器,则某些站点可能会配置为“intranet站点”。

是否检查了相关路径?如果您访问的路径如
/mycontroller/myaction/myparameter
(这是一个非常常见的默认asp路径)&您的css从上面被使用,它将试图从
/mycontroller/myaction/content/fonts/chunkfive.otf
等获取字体。它需要是一个绝对路径,或者包含更多的
。/
使用fiddler或浏览器中的网络工具查看它正在访问的内容我在任何日志中都没有看到任何404。我甚至下载了fiddler,但它提供了与NetworkCapture相同的功能——另外,请记住,在Chrome和Firefox中,所有这些都非常有用。如果这是一个路径问题,那么这些浏览器也不会工作。我今天要做这件事,我会让你知道的。谢谢你的回复。很好,我很惊讶更多的人没有发现这个。前几天我的回答也非常相似,几乎完全相同。我没有太高的期望,因为我没有体验到与你参考的其他帖子相同的事情。在其他浏览器中,所有这些都很好。只是没有,也就是说,对我来说,这也发生在其他浏览器中。值得一试。祝你好运。我已经更新了我的问题。如果你有任何其他的建议,我很乐意听听!再次感谢。