I use ASP.NET with web forms, something that should be really easy is driving me crazy, similar questions have been asked but none of them helped me, IE refuses to download my files.
Things to notice:
- I'm testing locally
- It works in Firefox and Chrome but not IE11
- IE changes file name to page's name (for example it tries to save default_aspx instead of myfile.pdf)
This is my code:
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "Application/pdf";
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.BinaryWrite(buffer);
Response.End();
These are the headers I got from IE:
Key Value
Response HTTP/1.1 200 OK
Cache-Control private
Content-Type Application/PDF
Server Microsoft-IIS/7.5
Content-Disposition attachment; filename=myfile.pdf
X-AspNet-Version 4.0.30319
X-Powered-By ASP.NET
Date Fri, 10 Apr 2015 22:44:40 GMT
Content-Length 691892
UPDATE
It seems like this is a server configuration issue because the same code will work fine in my production server but not in my development server. So my client won't complain about this, anyway I want to fix it in my development environment, as soon as I have time I'll investigate a little more, if I find a solution I'll post it here.