ASP.NET MVC: 500 Internal Server Error on requesting css, js, images, woff, woff2 resource files

Standard

I was working on deployment of Angular2 application with ASP.NET MVC 5 on Azure and came across this specific issue that all images of extension .woff and .woff2 were not loading successfully in browser, although path of these files were correct, Everything was working fine in local machine but after deployment on Azure it stop loading all sprites and images with mime of extension .woff, .woff2.

My project web.config has below code:

<staticContent>
  <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
  <mimeMap fileExtension=".woff2" mimeType="application/x-font-woff" />
</staticContent>

I checked all below scenario and there was no issue:

  • Check permissions in IIS and on disk for files
  • Check IIS setting for static files

Solution:

Where as I needed below code because newer version of IIS on Server 2012 has .woff and .woff2 already added in its MIME list, if we try to add same MIME again then it crash without giving any proper stack trace error and just went 500. So I remove faulty file extension and introduce proper MIME configuration in web.config all over again..

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

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s