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.