How to add the MIME type, web. configmime

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.