BetterCMS icon indicating copy to clipboard operation
BetterCMS copied to clipboard

Make mime types in EmbeddedResourcesController extensible

Open remyblok opened this issue 10 years ago • 1 comments

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");
...

remyblok avatar Oct 07 '15 21:10 remyblok

Thanks it's a great idea. Thanks.

ghost avatar Oct 09 '15 05:10 ghost