Add your own mime type to a Windows server using the web.config file

Last updated December 6th, 2023 06:07

Here is an example of how to add your own mime type to a Windows server using the web.config file.

				
					<configuration>
  <system.webServer>
    <staticContent>
      <mimeMap fileExtension=".custom" mimeType="application/x-custom"/>
    </staticContent>
  </system.webServer>
</configuration>

				
			
Add your own mime type to a Windows server using the web.config file

Add your own mime type to a Windows server using the web.config file – explanation

In this example, we are adding a new MIME type for files with the .custom extension. The MIME type we are adding is application/x-custom. Here’s what each part of the code does:

  • <configuration>: This is the root element of the web.config file.
  • <system.webServer>: This element contains configuration settings for IIS (Internet Information Services) web server.
  • <staticContent>: This element allows you to configure the static content (such as images, CSS files, and JavaScript files) that is served by your web application.
  • <mimeMap>: This element allows you to map a file extension to a MIME type.
  • fileExtension=".custom": This attribute specifies the file extension we want to map to a MIME type. In this case, we’re mapping the .custom extension.
  • mimeType="application/x-custom": This attribute specifies the MIME type we want to associate with the file extension. In this case, we’re using application/x-custom.

To use this code, you’ll need to add it to the web.config file for your web application. You can edit the web.config file using a text editor or an XML editor. Once you’ve added the code, save the file and upload it to your web server.

Note: Make sure to use the correct MIME type for the type of file you’re serving. You can find a list of common MIME types and their corresponding file types here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types

The website is created with care for the included information. I strive to provide high-quality and useful content that helps or inspires others. If you are satisfied with my work and would like to support me, you can do so through simple options.

Byl pro Vás tento článek užitečný?

Klikni na počet hvězd pro hlasování.

Průměrné hodnocení. 0 / 5. Počet hlasování: 0

Zatím nehodnoceno! Buďte první

Jak užitečný vidíte tento článek.

Sledujte mě na sociálních médiích.

Je mi líto, že pro Vás nebyl článek užitečný.

Jak mohu vylepšit článek?

Řekněte mi, jak jej mohu zlepšit.

newsletter

Subscribe to the Newsletter

Stay informed! Join our newsletter subscription and be the first to receive the latest information directly to your email inbox. Follow updates, exclusive events, and inspiring content, all delivered straight to your email.

Odebírat
Upozornit na
guest
0 Komentáře/ů
Nejstarší
Nejnovější Nejvíce hlasováno
Vložené zpětné vazby.
Zobrazit všechny komentáře.

Pokud mi chcete napsat rychlou zprávu, využije, prosím, níže uvedený
kontaktní formulář. Děkuji.

Další Kontaktní údaje