views:

37

answers:

1

Because of issues with the Content-Disposition header (character encoding, cross-browser support) I decided to give another way to dynamically serve files a try.

Namely, I redirect the request to something like:

localhost/Download/Page.aspx/filename-without-extension

in order for the browser to pick up the file name at the end. I also supply the correct Content-Type header (as determined by my ripped off System.Web.MimeMapping class).

Now, for ZIP files this actually works fine. The browser offers to save the file with the extension .zip. For all other file types I have tried (exe, pdf, doc), though, it won't suggest a file extension, which leaves the file unusable for most users.

I see only one option to get around this: I need to put the extension into the URL.

localhost/Download/Page.aspx/filename.ext

But doing so leads to a 404 error or similar because the web server will now look for the file in the subdirectory Page.aspx which doesn't exist.

Is there any configuration directive that would enable me to change this behavior for a particular subdirectory?

The project is a standard ASP.NET 3.5 Website. I would prefer a solution that doesn't involve complicated configuration in the IIS Manager. The best solution for me would be a directive in the ASPX file itself though that is unlikely to exist because this is a routing issue on the application level. But a Web.Config setting in a location tag would be nice.

A: 

I tried to replicate this error, and I got zip, word and PDF files working. I am wondering whether it is not working on Word and PDF because these extensions aren't properly registered on the client. On Windows clients, this is in the registry under HKEY_CLASSES_ROOT\Mime.

Mark Bertenshaw
ok, ZIP, PDF and DOC may work in some way or others (DOC won't work on my machine in IE8 (but in Safari), maybe because there's only OpenOffice and not Word - my header is application/msword, can you suggest a better one?A problem are EXE files though. They won't work in IE or Safari (or Opera for that matter).