Start a conversation

IIS7 Error: cannot add duplicate collection entry of type ‘mimeMap’

By contrast, in IIS7 & 7.5 (Windows Server 2008 & Server R2), adding the same mime types at the application level (which IIS will place into a web.config file) and the site level (which IIS will place into the applicationHost.config file) may cause a conflict.  No warning is given except for an error in the client browser that goes something like this:

Server Error in Application

Internet Information Services 7.0
HTTP Error 500.19 - Internal Server Error


MIME Types

There was an error while performing this operation.
Line number: 25
Error: cannot add duplicate collection entry of type ‘mimeMap’ with unique key attribute ‘fileExtension’ set to ‘.xyz’


One solution would be to simply remove one of the two conflicting mimeMap extensions from one of the config files.  However, in some rare scenarios the IIS administator may need to not remove one of the two conflicting mime mappings.  If both mimeMaps are needed, the way to get around the conflict is to make one simple addition to the web.config which will do a REMOVE immediately prior to doing an ADD.

So if your application installation adds the following line to the web.config. . .

           <mimemap fileExtension=".xyz" mimeType="xml/text" />

… And this line creates a conflict with the same mime map in the applicationhost.config file, all you have to do is add the following line ABOVE that line so that it will look like the following:

           <remove fileExtension=".xyz" />
           <mimemap fileExtension=".xyz" mimeType="xml/text" />
Doing the remove before the add should be fine even when the .xyz mime map doesn't exist at a higher level. 

Choose files or drag and drop files
Was this article helpful?
  1. Senior Engineer Jessie

  2. Posted
  3. Updated