This article is a mirror article of machine translation, please click here to jump to the original article.

View: 15595|Reply: 0

[ASP.NET] How to add MIME types in your ASP.NET's web.config configuration file

[Copy link]
Posted on 2/9/2017 1:08:55 PM | | |

There are often some special MIME types that are not found in IIS, and generally we have to add them manually.If the website frequently changes servers or the website code is provided to multiple users, then the special MIME types used in the website will need to be configured on IIS frequently. This is a website configuration commonality issue, so we can add the MIME type to the configuration file of ASP.NET website, so that users do not have to configure IIS all the time.

Generally speaking, we configure this part of the MIME information in the staticContent node of the system.webServer node, and only need to set the fileExtension file extension property and the mimeType MIME type property in the mimeMap node.

The approximate code is as follows (the extension and MIME type added to the code are just as examples):


You can see that 3 extensions are added here that are not in IIS default:

.woff (woff font)
.xap (Silverlight compiled file)
.xaml (eXtensible Application Markup Language)
An additional point to note here is thatIn the above code, I also declared the remove node to prevent the website from appearing with this anomalous message due to repeated MIME typesIf your website does not prompt this exception message, or you can be sure that these extensions must not be configured on the user's IIS, then you do not need to add the remove node.






Previous:Split parameter StringSplitOptions.RemoveEmptyEntries
Next:Log4Net logs to the SQLServer database
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com