Azure引导字体

似乎无法解决这个问题,我将自定义引导程序css和字体插入到我的azure色cdn中,但在chrome中我一直得到“来自原点的字体” http://azxxxxxx.vo.msecnd.net ‘已被阻止加载由Cross-Origin资源共享策略:请求的资源上不存在“Access-Control-Allow-Origin”标头。因此不允许来源“ http://localhost.domain:16300 ”。

我修改了我的bootstrap css

font-face { font-family: 'Glyphicons Halflings'; src: url('//azxxxxxx.vo.msecnd.net/fonts/glyphicons-halflings-regular.eot'); src: url('//azxxxxxx.vo.msecnd.net/fonts/glyphicons-halflings-regular.eot?#iefix') format('embedded-opentype'), url('//azxxxxxx.vo.msecnd.net/fonts/glyphicons-halflings-regular.woff') format('woff'), url('//azxxxxxx.vo.msecnd.net/fonts/glyphicons-halflings-regular.ttf') format('truetype'), url('//azxxxxxx.vo.msecnd.net/fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular') format('svg'); } 

我已经阅读了一些stackoverflowpost,将以下内容添加到我的webconfig中

          

仍然有同样的问题,任何想法?

假设您已将字体/ CSS上传到Azure存储,并使用Azure CDN。

您需要在存储上启用CORS以允许您的站点跨域访问字体。

Windows Azure存储中介绍了完整的步骤:介绍CORS

文章中的部分示例(您需要获取NuGet以获取最新的Azure客户端库来构建它):

 private static void InitializeCors() { // CORS should be enabled once at service startup // Given a BlobClient, download the current Service Properties ServiceProperties blobServiceProperties = BlobClient.GetServiceProperties(); ConfigureCors(blobServiceProperties); BlobClient.SetServiceProperties(blobServiceProperties); } private static void ConfigureCors(ServiceProperties serviceProperties) { serviceProperties.Cors = new CorsProperties(); serviceProperties.Cors.CorsRules.Add(new CorsRule() { AllowedHeaders = new List() { "*" }, AllowedMethods = CorsHttpMethods.Get | CorsHttpMethods.Head, AllowedOrigins = new List() { "*" }, ExposedHeaders = new List() { "*" }, MaxAgeInSeconds = 1800 // 30 minutes }); } 

看起来你缺少一些步骤(和自定义标题)。 看看这个答案,它可能有你需要的东西 – 由于CORS,Azure网站上的请求失败了

我相信这是我不久前的问题。 追踪是一只熊。 最后,对我有用的是为各种字体格式添加MIME类型。 显然,Azure的服务器映像已经没有正确包含它们。 这是您要尝试的web.config文件的更新。

             

请注意更新的mimeType值。 祝好运!

做这个。

IIS ver 7.5+

IIS ver <7.5


一种完全不同的方法是将eot文件编码为base64并将它们直接嵌入到CSS文件中。 最近,当我无法访问.woff字体文件时,我不得不为HTML Windowsapp store应用做这.woff