BetterCMS
BetterCMS copied to clipboard
Make mime types in EmbeddedResourcesController extensible
I have a module with embedded resources. One of the resources is a style sheet that references custom fonts. These fonts are also embedded. The fonts are not served because the mime type / extension is not supported. This is blocked by the EmbeddedResourcesController. This controller hold a list of valid mime types, but the list is not open for adding custom types.
I would like to propose to add AddCustomMimeType(string mimeType, string fileExtension) as a static method on EmbeddedResourcesController so that mime types can be controlled per web application.
My current work around is to add the types using reflection.
var field = typeof(EmbeddedResourcesController).GetField("MimeTypes", BindingFlags.Static | BindingFlags.NonPublic);
IDictionary<string, string> mimeTypes = (Dictionary<string, string>)field.GetValue(null);
mimeTypes.Add("eot", "application/vnd.ms-fontobject");
mimeTypes.Add("otf", "application/font-otf");
...
Thanks it's a great idea. Thanks.