oscilatingcretin
oscilatingcretin

Reputation: 10919

ASP.NET WebForms: Why can't I download certain files that I've uploaded through my application?

I have a simple asp:FileUpload control that saves a file to the server. It saves the file to disk then creates a path reference to it in the database. We display these files in a DataGrid using this markup:

<ItemTemplate>
    <a href='<%# MyApp.Global_asax.UploadPath + DataBinder.Eval(Container.DataItem, "FolderName") + "/" +  DataBinder.Eval(Container.DataItem, "FileName") %>' target="_blank">
        <%# DataBinder.Eval(Container.DataItem, "FileName") %>
    </a>
</ItemTemplate>

So, as you can see, it's nothing special. However, trying to download some files results in this message in IE9:

The page cannot be found
The page you are looking for might have been removed, had its name changed, or is temporarily unavailable. 

I get a similar message in FireFox.

So far, this is happening only with .DOTM files. I thought it could be the file name, so I changed the name to something simple like xxx.dotm, but this still doesn't download. When I change the extension to TXT so it's xxx.txt, though, I am able to download the file just fine.

Is anyone able to give me an idea as to what's going on here?

Upvotes: 0

Views: 221

Answers (1)

Miyagi Coder
Miyagi Coder

Reputation: 5532

You need to add the MIME type in IIS for that file extension.

For IIS 6.0:

http://support.microsoft.com/kb/326965

For IIS 7.0:

http://technet.microsoft.com/en-us/library/cc725608(v=ws.10).aspx

Upvotes: 3

Related Questions