ASP.NET MVC / IIS 7.5: 500 Internal Server Error for static content only

16,791

Solution 1

I enabled Failed Request tracing and after searching through the (enormous) log, I discovered this:

 <EventData>
  <Data Name="ContextId">{00000000-0000-0000-3700-0080010000FC}</Data>
  <Data Name="ModuleName">CustomErrorModule</Data>
  <Data Name="Notification">536870912</Data>
  <Data Name="HttpStatus">500</Data>
  <Data Name="HttpReason">Internal Server Error</Data>
  <Data Name="HttpSubStatus">19</Data>
  <Data Name="ErrorCode">2147942583</Data>
  <Data Name="ConfigExceptionInfo">
    \\?\C:\Websites\xxx\www\web.config ( 58) :Cannot add duplicate collection 
    entry of type &apos;mimeMap&apos; with unique key attribute 
    &apos;fileExtension&apos; set to &apos;.woff&apos;
  </Data>
 </EventData>

What has happened is, a new Mime type for serving web-fonts (.woff) had been explicity added to the site.

Later on, the new Mime type (.woff) had also been added to the global IIS mime types.

Instead of the website setting overriding the global setting, an exception was being thrown.

Solution 2

Always remove any mimetype you want to add, just in case it's already defined at the IIS/server level, eg:

<staticContent>
  <remove fileExtension=".otf" />
  <mimeMap fileExtension=".otf" mimeType="application/x-font-otf" />
</staticContent>

Solution 3

finally solved this 500 Internal server error when deploying MVC 3.0 application on godaddy.ocm shared hosting

somehow there were discrepancies on the version of DLLs referenced and version mentioned in web.config.

Tried all the options mentioned in various forum, Nothing helped, although everyone suggested same kind of fix, but somehow didnt work in my scenario. finally after banging my head for 2 days. i decided to deleted all dll reference and delete web.cofig( make a local copy) from project and let application throw error and then add dll one by one making copy to local=true. after all the dlls are added. i created a new asp.net mvc application and copied the web.config of new app to my actual app. so my actual app now has a new web.config, then i copied the connectionstring and other reference from the local copy of web.config that i saved .

just compiled the application and published to local folder and FTP the published folder to goDaddy

It worked and finally my problem was solved

Hope this will help people and they dont waste 2 days like me,

Share:
16,791
nrkn
Author by

nrkn

Updated on June 05, 2022

Comments

  • nrkn
    nrkn about 2 years

    An ASP.NET MVC project running under IIS 7.5 (but problem may exist on earlier versions and non-MVC sites) which was previously working has started returning 500 Internal Server Error but only for content handled by the static handler - images, pages etc. handled by MVC itself through a controller work fine.

    I know what caused it - I am documenting this in case somebody else has the same problem.

  • nrkn
    nrkn over 11 years
    I haven't tested it but I wouldn't be surprised if attempting to override other settings in web.config vs. global would also cause this.
  • Nick Bork
    Nick Bork over 11 years
    Great question, thanks for posting it. Things were working on a DEV server and the client purchased hosting using GoDaddy. After deploying the site we got 500 errors for any request to static content (CSS, Images, etc). We added a static content mime map for .SVG to map to image/svg+xml since IIS doesn't have one by default. Your answer was exactly what I needed, we removed the static content map from our web.config, reuploaded and it solved the issue.
  • nrkn
    nrkn over 11 years
    Glad it helped! It's a pretty nasty error - took me a while to figure it out.
  • TobyEvans
    TobyEvans almost 11 years
    I got woffed too! Exact same thing ... cheers, had me totally baffled
  • Gonzalo Gallotti
    Gonzalo Gallotti almost 11 years
    Exact problem! Saved me hours of research!
  • ianbeks
    ianbeks over 10 years
    For me it was .json. Thanks for the time saver!
  • vittore
    vittore almost 10 years
    @ianbeks yeap, exactly same story with .json
  • Clarkey
    Clarkey over 9 years
    Same problem here.. I had .gem MIME type added to the website and the working folder..
  • Meoiswa
    Meoiswa almost 9 years
    Testing a WebApp in Windows 10 continuously gave 500 Internal server error because of this line (which was required in windows 8.1 before) Adding the remove tag first made it work in both environments