39

I'm using Visual Studio 2012 with Update 2 and IIS Express.

When I add a record to the staticContent section, all other static content (.js, .css, .jpg, etc) returns a 500 error.

Any advice would be greatly appreciated. Thanks in advance.

Aaron Drenberg
  • 1,117
  • 2
  • 11
  • 29

3 Answers3

93

The mimetype is probably already added to your IIS.

Try to remove the mimetype first and then add it again in your web.config

<remove fileExtension=".woff"/>
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />

Good luck!

Madelene
  • 970
  • 7
  • 7
  • I second @Madelene answer. I recently had this same issue on a web hosting provider. I think they must have changed this in time, as months ago the same Web.config did not cause any issue. I figured out that the offending line was that .woff one, hence I tried by first removing the extension first, and it worked. – superjos Oct 04 '13 at 21:26
  • 1
    Thanks very much for the replies! This was the correct solution. – Aaron Drenberg Nov 14 '13 at 16:15
  • I just stumbled on this error when i switched from VS2010 to VS2013, Since it's already declared in the IIS it caused an error. No idea why it's handled properly in 2010 but not 2013 though – Anders Vedal Pettersen Jan 29 '14 at 09:15
  • Funny we had the same exetension .woff with same issue. – JonH Sep 10 '14 at 19:33
  • I had the same issue in VS2015 with IIS10 Express. Thanks for the solution ;) – kapsiR Nov 19 '15 at 17:56
  • I was adding woff & woff2 extensions because when I deployed to Azure the site crashed immediately - although it ran fine locally. Adding the file extensions to the web.config fixed the Azure deployment but then my local environment was hosed. This answer got me back on track :-) – DilbertDave Jan 16 '17 at 09:28
1

Behavior of system.webServer/staticContent/mimeMap element has changed in IIS 7.0 and apparently one has to list all types explicitly to have them returned properly.

Here is a description from IIS configuration documentation:

Note: IIS 7 will not return file types that are not added to the element or that have mappings in the element by default. This behavior prevents unauthorized access to files that do not have mappings in the IIS 7 configuration settings.

Tomasz Poradowski
  • 1,251
  • 11
  • 12
  • what exactly are you answering – tod Dec 11 '14 at 09:07
  • @tod second line of the main question: `When I add a record to the staticContent section, all other static content (.js, .css, .jpg, etc) returns a 500 error.` this was caused by the changed behavior of `staticContent` section, thus all extensions need to be listed explicitly – Tomasz Poradowski Dec 12 '14 at 13:57
0

If you are using IIS Express in visual studio then there is no need to define staticContent so remove it.

By default, Visual studio IIS Express allow all MIME types.

jherran
  • 3,337
  • 8
  • 37
  • 54
Rajiv
  • 1,245
  • 14
  • 28