Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Possible to add MIME type to web.config without possibly breaking the site?

Tags:

asp.net

iis

iis-7

I had a web.config in one of the websites on my IIS that was adding a support for .7z file extension. When I later added a global .7z support at the server level, this site was broken - IIS Manager is complaining that it "cannot add duplicate collection entry of type 'mimeMap'..." and all web requests to i.g. CSS files ended with an HTTP 500 error.

I was using this in the site's web.config:

<system.webServer>     <staticContent>         <mimeMap fileExtension=".7z" mimeType="application/x-7z-compressed" />     </staticContent> </system.webServer> 

Is there maybe some other syntax that would add 7z to the list only if it wasn't defined yet?

like image 261
Borek Bernard Avatar asked Sep 01 '13 20:09

Borek Bernard


People also ask

How do I add a MIME type?

In the Connections pane, go to the site, application, or directory for which you want to add a MIME type. In the Home pane, double-click MIME Types. In the MIME Types pane, click Add... in the Actions pane. In the Add MIME Type dialog box, add the file name extension and MIME type, and then click OK.

Where do I put MIME type in HTML?

Look for a <meta> element in the page source that gives the MIME type, for example <meta http-equiv="Content-Type" content="text/html"> . According to the standards, the <meta> element that specifies the MIME type should be ignored if there's a Content-Type header available.


1 Answers

According to this, you should remove the global setting in the special config before adding it in a different form.

Explcitly:

<system.webServer>     <staticContent>         <remove fileExtension=".7z" />         <mimeMap fileExtension=".7z" mimeType="application/x-7z-compressed" />     </staticContent> </system.webServer> 

Of course this doesn't really help you now as you might just as well drop the local setting completely (as it's likely to coincide with the global setting). But if you had known this back when you added local 7zip support, you wouldn't have encountered the error now ...

like image 94
Hagen von Eitzen Avatar answered Oct 13 '22 20:10

Hagen von Eitzen