Question

To support an installation on IIS 7, I added the following to my web.config:

<system.webServer>
  <staticContent>
    <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
  </staticContent>
</system.webServer>

This worked fine in IIS7 (and express) as .mp4 wasn't included by default. Now that I'm trying to run the solution under VS2012 with IIS8 Express, no static content is served, and instead I have an error that the <staticContent> is invalid as there's already a mimeMap for .mp4.

How can I correct this while still keep the mapping for IIS7 installations? I'd rather not need a new project configuration if I can help it.

EDIT: This is actually a problem in VS2010 now, since it looks like IIS8 Express completely replaces IIS7 Express.

Was it helpful?

Solution 2

Explicitly remove the mapping first:

<system.webServer>
  <staticContent>
    <remove fileExtension=".mp4" />
    <mimeMap fileExtension=".mp4" mimeType="video/mp4" />
  </staticContent>
</system.webServer>

This works even if there's no mapping to remove.

OTHER TIPS

There is likely a better way to do this, but what I did was go into the applicationhost.config file that IIS Express is using and find and comment out the mimeMap setting like this:

<!--            <mimeMap fileExtension=".m4v" mimeType="video/mp4" /> -->
<!--            <mimeMap fileExtension=".mp4" mimeType="video/mp4" /> -->

After making this change you can leave the web.config mimeMap settings and it will work on IIS7 and IIS8 Express.

If you need to know which applicationhost.config file IIS Express is using just right click on the IISExpress icon in the notification area icons (right side of your taskbar), then click "show all applications", then click the site name (not the URL) of the site you're developing for and it will show details about the site below, including the config file path. Sorry if this seems trivial, I had a tough time finding my config file as it ended up on a remote file server.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top