How to add the MIME type, web. configmime
Some special MIME types are not available in IIS. Generally, we need to manually add them. If the website frequently changes the server or the website code is provided to multiple users, special MIME types used in the website will be frequently configured on IIS. Considering a General website configuration problem, we can add the MIME type to the configuration file of the ASP. NET website so that you do not need to configure IIS all the time.
In general, we configure this part of MIME information in the staticContent node of the system. webServer node. During configuration, we only need to set the fileExtension file extension attribute in the mimeMap node and the mimeType MIME type attribute.
The approximate code is as follows (the extension and MIME Type added in the Code are only used as an example ):
<system.webServer> <staticContent> <remove fileExtension=".woff" /> <remove fileExtension=".xap" /> <remove fileExtension=".xaml" /> <mimeMap fileExtension=".woff" mimeType="font/x-font-woff" /> <mimeMap fileExtension=".xap" mimeType="xapapplication/x-silverlight"/> <mimeMap fileExtension=".xaml" mimeType="application/xaml+xml"/> </staticContent></system.webServer>
We can see that three extensions not available in IIS by default are added here:
Note that in the above code, I also declared the remove node to remove the node. This is to prevent the website from this exception caused by repeated MIME types: set "fileExtension" in the unique key attribute to ". woff, you cannot add repeated collection items of the type "mimeMap". If your website does not prompt this exception, or you can determine that the user's IIS does not have to configure these extensions, so you do not need to add remove nodes.
This article Reprinted from: http://shiyousan.com/post/635425176495182735