Blog.jirivanek.eu      Digitální zápisník

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

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>

				
			

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

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.

Odebírat
Upozornit na
guest
0 Komentáře/ů
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