Q:

C# Razor Website Download custom extension file 404 error

I have a simple anchor link that needs to download a file from the server. The file name is:  "RT350Z_cfg.modbus".  I believe the server cannot recognize the file type so it is giving me a 404 error.
The exact path of the file is: 
~/uploads/UNITS/docs/VFD/RT350Z_cfg.modbus
My cshtml file simply has this:
 <a target="_blank" href="@(VirtualPathUtility.ToAbsolute("~/uploads/UNITS/docs/VFD/RT350Z_cfg.modbus"))">Download File</a>

When I click on the link I get a 404 error not found. I have triple checked that the file exists in that location of the server. 
I then modified the extension to a *.txt file and revised the hyperlink to look for the txt file.
<a target="_blank" href="@(VirtualPathUtility.ToAbsolute("~/uploads/UNITS/docs/VFD/RT350Z_cfg.txt"))">Download File</a>

When I physically modified the extension to a *.txt file, and then changed the hyperlink - the file downloaded just fine.
How do I allow my web application to download custom file extensions?

A:

Some versions of IIS do not serve 'unknown' files.
You can configure your web.config to treat the file as you want:
<system.webServer>
    <staticContent>
      <mimeMap fileExtension=".modbus" mimeType="text/plain" />

or for binary:
<mimeMap fileExtension=".modbus" mimeType="application/octet-stream" />

You can read more about it at MSDN.

