Hi Guys,
We had a weird problem at work where our font files won’t load.
One of my colleague Dr. Overton who is working on web services using Service stack for one of our project showed me what the problem was.
Now I am 80% web guy and 20% applications. So for once I was like ok its something to do with configurations.
That turned out to be true
By default these extensions are allowed
[geshi lang=”csharp” nums=”1″ target=”_self” ]
1 2 3 4 5 6 7 |
AllowFileExtensions = new HashSet(StringComparer.InvariantCultureIgnoreCase) { "js", "css", "htm", "html", "shtm", "txt", "xml", "rss", "csv", "jpg", "jpeg", "gif", "png", "ico", "tif", "tiff", "bmp", "avi", "divx", "m3u", "mov", "mp3", "mpg", "qt", "vob", "wav", "wma", "wmv", "flv", "xap", "xaml", "mpeg" } |
As you can see that AllowFileExtensions is just a Collection Object property (which we can add extensions to) under class EndPointHostConfig
So within your AppHost.cs file where you are creating EndpointHostConfig config object as shown below
1 2 3 4 |
EndpointHostConfig config = new EndpointHostConfig { .... } |
After this declaration just add required extensions. In our case we want to process few font files that won’t work otherwise without these changes
[geshi lang=”csharp” nums=”1″ target=”_self” ]
1 2 3 4 5 |
string[] exts = {"png", "woff", "ttf", "svg"}; foreach (string ext in exts) config.AllowFileExtensions.Add(ext); base.SetConfig(config); |
Advertisement
Much thanks to Dr Overton to figure this out.
I hope this helps someone
Cheers
Leave a Reply