marcos.borunda
marcos.borunda

Reputation: 1486

PDF download fails showing message "Couldn't be downloaded" only in IE11

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:

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.

Upvotes: 17

Views: 4750

Answers (4)

user917170
user917170

Reputation: 1641

I have had similar issues in the past, I would try setting the response content length explicitly.

Response.AddHeader("Content-Length", buffer.Length.ToString())

Upvotes: 1

Language Lassi
Language Lassi

Reputation: 2630

This is not the exact answer but hope if it can open some ways to find the exact one.

While googling I found this may be due to a security update release by Microsoft for IE.

Microsoft released a security update for IE11 on 8 Jul 14 which has a bug affecting the download.

And here is the Microsoft Connect Link that mention this under active status.

Please share exact solution once you find it.

Cheers!!

Upvotes: 3

Mihai
Mihai

Reputation: 518

We had a similar issue in ie8 the problem is that the file is searched in the cache and is not found. To test this please set Cache-Control : no-cache in your response object.

Upvotes: 5

basher
basher

Reputation: 2401

I do something similar in my own app. Try removing the content-disposition header and change Application/pdf to application/pdf. You also likely don't need Response.End(), though I doubt that is what is causing the problem.

Upvotes: 2

Related Questions