Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS Express - HTTP Error 500.19 0x800700b7 on 'mimeMap' for 'fileExtension' set to '.svg'

I was adding the ability to serve SVG & WOFF files to my Azure hosted web application. I found the following instructions:

https://blogs.iis.net/richma/archive/2014/01/07/adding-mime-types-to-your-windows-azure-web-site.aspx

Which I have followed by adding the below text to my Web.config file:

<staticContent>     <mimeMap fileExtension=".json" mimeType="application/json" />     <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />     <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" /> </staticContent> 

This works when published to Azure. However, now I get the following error from IIS-Express whenever I attempt to start up the website in Debug mode locally for every resource the website attempts to serve.

HTTP Error 500.19 - Internal Server Error

The requested page cannot be accessed because the related configuration data for the page is invalid.

Detailed Error Information:

  • Module: CustomErrorModule
  • Notification SendResponse
  • Handler StaticFile
  • Error Code 0x800700b7
  • Config Error Cannot add duplicate collection entry of type 'mimeMap' with unique key attribute 'fileExtension' set to '.svg'
  • Config File snip\web.config
  • Requested URL http://snip:14466/resources/img/snip.png
  • Physical Path C:*snip*\Resources\img*snip*.png
  • Logon Method Anonymous
  • Logon User Anonymous

Config Source:

   58: <mimeMap fileExtension=".json" mimeType="application/json" />    59: <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />    60: <mimeMap fileExtension=".woff" mimeType="application/x-font-woff"/> 

It clearly hates my mimeMap for .svg but this works fine out in Azure Websites. Is there something I am missing for locally running these changes to the Web.config?

like image 207
Jesse VanDerPol Avatar asked Apr 28 '14 20:04

Jesse VanDerPol


1 Answers

And of course I find this answer after already posting my question:

Adding <mimeMap> entry Causes 500 for Other Static Content on IIS Express

So the issue is that my local IIS configuration has the modules already loaded, meanwhile the production environment doesn't. So to fix the issue for both environments you need to make sure the mimeMaps are unloaded before loading them.

The code is the following for the fix:

<staticContent>     <remove fileExtension=".json"/>     <mimeMap fileExtension=".json" mimeType="application/json" />     <remove fileExtension=".svg"/>     <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />     <remove fileExtension=".woff"/>     <mimeMap fileExtension=".woff" mimeType="application/x-font-woff"/> </staticContent> 

Hope this helps others from wasting time looking for a fix.

like image 182
Jesse VanDerPol Avatar answered Sep 16 '22 14:09

Jesse VanDerPol