Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / IIS

Configure IIS to Allow Any File Type to be Downloaded

4.50/5 (3 votes)
16 Feb 2018CPOL1 min read 35.1K  
Configure IIS to allow any file type to be downloaded

Introduction

This tip discusses how to configure IIS to allow any file type to be downloaded.

Background

Many times requirements come into our projects where we want to allow a new file extension to be supported by our IIS.

For example, I want to allow a file with extension ‘.newextension’ to be served by IIS when a user requests a file that contains this file extension.  

Using the Code

For allowing a new file extension, we need to allow a new file extension in MIME types. In our case, I need to add ‘.newextension’ in MIME type.

What are MIME Types?

MIME types basically identify the type of request. If a user requests a file that is not mapped in MIME type, IIS will throw an exception.

‘The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.’

For allowing a new file extension, we need to add a new MIME type. For adding a new MIME type, we need to supply ‘File name extension’ and ’MIME type’. In my case, file name extension will be ‘.newextension and MIME type will be ‘text/plain’ because I just want to view the contents of file.

Once we allow a new file extension, IIS will serve that new file extension.

Request: http://XX.XXX.XX.XX/SampleWeb/test. newextension .

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)