由于字体可怕的4.3,他们添加字体为woff2格式。
当我试图通过owin提供此文件时,我正在引导404 to:
app.UseFileServer(new FileServerOptions() {
RequestPath = PathString.Empty,
FileSystem = new PhysicalFileSystem(@"banana")
});如何通过owin中的文件服务器提供woff2 mime类型文件?
发布于 2017-07-10 14:33:22
您可以通过使用继承来避免不太好的转换:
FileServerOptions options = new FileServerOptions
{
StaticFileOptions =
{
ContentTypeProvider = new CustomFileExtensionContentTypeProvider(),
}
};哪里
private class CustomFileExtensionContentTypeProvider : FileExtensionContentTypeProvider
{
public CustomFileExtensionContentTypeProvider()
{
Mappings.Add(".json", "application/json");
Mappings.Add(".mustache", "text/template");
}
}发布于 2015-02-11 14:43:10
有两种可能性:
var options = new FileServerOptions() {
RequestPath = PathString.Empty,
FileSystem = new PhysicalFileSystem(@"banana")
};
options.StaticFileOptions.ServeUnknownFileTypes = true;
app.UseFileServer(options);var options = new FileServerOptions() {
RequestPath = PathString.Empty,
FileSystem = new PhysicalFileSystem(@"banana")
};
((FileExtensionContentTypeProvider)options.StaticFileOptions.ContentTypeProvider)
.Mappings.Add(".woff2", "application/font-woff2");
app.UseFileServer(options);第二种选择似乎不那么优雅,但仍然是最好的选择。读why mime types are important。
https://stackoverflow.com/questions/28457090
复制相似问题