Knowledgebase
IIS7 Error: cannot add duplicate collection entry of type ‘mimeMap’
Posted by Sean Syed on 21 February 2013 07:10 PM

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.
Details
Filename
\\?\c:\something\something\.....\web.config
Line number: 25
Error: cannot add duplicate collection entry of type ‘mimeMap’ with unique key attribute ‘fileExtension’ set to ‘.xyz’

Solution:

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. 

(13 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below (we use this to prevent automated submissions).