Experiences from using existing projects within VS2015
I've been using VS2015 since an early preview at home but now it's launched I've been trialling it with many of our solutions within work trying to iron out any associated pain before we upgrade every developer (that hasn't already ;)).
One thing I've noticed across a few of our web projects that's caught a few people out is an issue with the new version of IIS Express, and actually if we ever got to deploying to IIS 10.
For many of our web projects we have added additional mimeTypes via the web.config to allow IIS to serve up woff2 files, previously you would have done this via:
However IIS 10, and therefore IIS Express 10, now handles this mimeType automatically. When you run your existing projects via VS2015 you will find all of your websites styling and images suddenly disappear. This can be quite alarming and confusing as the dynamic ASP.Net content loads fine, but all of your static content doesn't.
By using dev tools to investigate the request and response for one of the static resources you will find:
This nicely points out the issue, the static file handler already knows about the woff2 mimetype, the trick now is how to solve this for IIS 10 but still maintain the fix for older versions. This is as simple as removing the existing mimemap for the fileExtension before adding it.
This seems a bit mad as I had expected that if an add duplicate would fail wouldnt a removal of a non existing item, but meh it works ;)
So there we have it an odd issue that's actually really simple to resolve. I hope any other issues I find are as easy to fix ;)
One thing I've noticed across a few of our web projects that's caught a few people out is an issue with the new version of IIS Express, and actually if we ever got to deploying to IIS 10.
For many of our web projects we have added additional mimeTypes via the web.config to allow IIS to serve up woff2 files, previously you would have done this via:
<system.webServer> <staticContent> <mimeMap fileExtension=".woff2"mimeType="application/font-woff2" /> </staticContent> </system.webServer>
However IIS 10, and therefore IIS Express 10, now handles this mimeType automatically. When you run your existing projects via VS2015 you will find all of your websites styling and images suddenly disappear. This can be quite alarming and confusing as the dynamic ASP.Net content loads fine, but all of your static content doesn't.
By using dev tools to investigate the request and response for one of the static resources you will find:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)When you then look at the response you find:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Config Error | Cannot add duplicate collection entry of type 'mimeMap' with unique key attribute 'fileExtension' set to '.woff2' |
---|
<system.webServer> <staticContent> <remove fileExtension=".woff2" /> <mimeMap fileExtension=".woff2" mimeType="application/font-woff2" /> </staticContent> </system.webServer>
This seems a bit mad as I had expected that if an add duplicate would fail wouldnt a removal of a non existing item, but meh it works ;)
So there we have it an odd issue that's actually really simple to resolve. I hope any other issues I find are as easy to fix ;)
Good to know. I'm using vs 2015 but still on win 8.1. I would've hit this in a week or two when I upgraded to win 10. Thanks for sharing
ReplyDeleteGood to know. I'm using vs 2015 but still on win 8.1. I would've hit this in a week or two when I upgraded to win 10. Thanks for sharing
ReplyDeleteHah, certainly caught me off-guard. I just moved from VS2013 Ultimate to VS2015 Community and loaded up my project to find all styling missing. Very confusing, luckily searching the error brought me here quickly.
ReplyDeleteYou hero!! My file type was mp4 but the same fix also applied for the same problem - just remove the entry from web.config and try again.
ReplyDeleteThanks for taking the time to post this Michael.
Thank you :)
ReplyDeleteYou legend! Thanks for this tip (I was losing my mind!)
ReplyDeleteYou legend! Thanks for this tip (I was losing my mind...)
ReplyDelete