Reputation: 4700
Since font awesome 4.3, they added the fonts as woff2 format.
I'm guetting 404ed when trying to serve this file through owin :
app.UseFileServer(new FileServerOptions() {
RequestPath = PathString.Empty,
FileSystem = new PhysicalFileSystem(@"banana")
});
How do I serve woff2 mime type files through file server in owin ?
Upvotes: 1
Views: 1301
Reputation: 1305
You can avoid the not-very-nice casting by using inheritance:
FileServerOptions options = new FileServerOptions
{
StaticFileOptions =
{
ContentTypeProvider = new CustomFileExtensionContentTypeProvider(),
}
};
where
private class CustomFileExtensionContentTypeProvider : FileExtensionContentTypeProvider
{
public CustomFileExtensionContentTypeProvider()
{
Mappings.Add(".json", "application/json");
Mappings.Add(".mustache", "text/template");
}
}
Upvotes: 3
Reputation: 4700
Two possibilities :
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);
Second options seems not as elegant but is nonetheless the best. Read why mime types are important.
Upvotes: 9