Aus*_*ipe 56 asp.net asp.net-mvc-5 woff2
我正在使用VNext + OSX + Chrome进行一些实验.我正在尝试获取woff2文件
GET http://localhost:5003/fonts/fontawesome-webfont.woff2?v=4.3.0 
但是会发生错误.请参阅下面的请求标题
Remote Address:127.0.0.1:5003
Request URL:http://localhost:5003/fonts/fontawesome-webfont.woff2?v=4.3.0
Request Method:GET
Status Code:404 Not Found
这是我的Startup.cs
    public void Configure(IApplicationBuilder app)
    {
        app.UseStaticFiles();
        app.UseServices(services =>
        {
            services.AddMvc();
        });
        // Add MVC to the request pipeline
        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller}/{action}/{id?}",
                defaults: new { controller = "Home", action = "Index" });
        });
    }
我在Github的AspNet项目里面看到了StaticFiles(Link bellow),它似乎得到了支持.
你们能给我一些帮助吗?
mez*_*tou 123
文件格式woff2位于映射列表中,但最近添加(2015年2月),因此您可能不会使用包含此更改的版本.因此,要添加自定义文件格式,您可以使用IIS方式web.config:
<system.webServer>
  <staticContent>
    <remove fileExtension=".woff2" />
    <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
  </staticContent>
</system.webServer>
或使用StaticFilesOptions:
public void Configure(IApplicationBuilder app)
{
    StaticFileOptions options = new StaticFileOptions();
    FileExtensionContentTypeProvider typeProvider = new FileExtensionContentTypeProvider();
    if (!typeProvider.Mappings.ContainsKey(".woff2"))
    {
        typeProvider.Mappings.Add(".woff2", "application/font-woff2");
    }
    options.ContentTypeProvider = typeProvider;
    app.UseStaticFiles(options);
}
小智 15
在您的web.config中添加一个mime类型声明
<system.webServer>
    <staticContent>
      <mimeMap fileExtension=".woff2" mimeType="application/font-woff" />
    </staticContent>
</system.webServer>
有关详情,请参阅:
快速修复:在asp.net mvc中找不到IIS .woff字体文件404
| 归档时间: | 
 | 
| 查看次数: | 38932 次 | 
| 最近记录: |