How to add MIME types to the Web. config configuration file in ASP.

Source: Internet
Author: User
Tags silverlight

There are often some special MIME types that are not in IIS and are generally added manually by ourselves. If the site frequently changes the server or the site code is provided to multiple users, it will cause the special MIME type used in the site to be regularly configured on IIS. Given the commonality of a Web site configuration, we can add MIME types to the ASP. NET site configuration file so that users don't have to configure IIS all the time.

In general, we are configuring this part of the MIME information in the Staticcontent node of the system.webserver node, as long as the fileextension file extension attribute in the MimeMap node is set and MimeType this MIME type property (Click this link Common MIME types).

The approximate code is as follows (the extensions and MIME types added in the code are just examples):

  <System.webserver><Staticcontent><Removefileextension=". Woff"/><Removefileextension=". xap"/><Removefileextension=". xaml"/><mimemap fileExtension=mimetype= "Font/x-font-woff"/ > <mimemap fileExtension=< Span class= "Hljs-value" ". xap" mimetype= "xapapplication/ X-silverlight "/> <mimemap  Fileextension=mimetype=</staticcontent> </SYSTEM.WEBSERVER>       

You can see that there are 3 extensions that are not available by default in IIS:

    1. . Woff (Woff font)
    2. . XAP (Silverlight compiled file)
    3. . xaml (Extensible Application Markup Language, extensible Application Markup Language)

It is important to note that in the above code I have also declared remove, which removes the node, in order to prevent this exception from being added to the Web site by repeating the addition of the MIME type: "The unique key property" FileExtension "cannot be added when the". Woff "is set to" MimeMap "Duplicate collection items", if your site does not prompt this exception information, or can be determined that the user's IIS must not be configured on these extensions, then the Remove node can not be added.

How to add MIME types to the Web. config configuration file in ASP.

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.