Billy
Billy

Reputation: 15706

Internet Explorer shows error when downloading excel file in SSL site

I get the following error when downloading excel file in SSL site:

Internet Explorer cannot download xxxx.aspx from mysite.com.  
Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.

After googling, I suspect that it's the problem of the response header.
I try the solution in this page and set the header:
http://trac.edgewall.org/ticket/1020

            HttpContext.Current.Response.AddHeader("Pragma", "no-cache");
            HttpContext.Current.Response.CacheControl = "private";

But it doesn't work. Any suggestions?

Upvotes: 2

Views: 9700

Answers (4)

Rufel
Rufel

Reputation: 2660

I had a similar problem with PDF files I wanted to stream. Even with Response.ClearHeaders() I saw Pragma and Cache-Control headers added at runtime. The solution was to clear the headers in IIS (Right-click -> Properties on the page loading the PDF, then "Http headers" tab).

Upvotes: 1

Vinod T. Patil
Vinod T. Patil

Reputation: 2961

I also faced the same issue,

When I googled it, I found that "no chache" settings in response header i.e. following code is the reason for the issue.

Response.AppendHeader("Pragma", "no-cache")
Response.AppendHeader("Cache-Control", "no-cache")
Response.AppendHeader("max-age", "0")

Some of the blogs says, to fix this issue, you should do some modification in Windows registry on Webserver and on all client machines(:O), well it is not feasible to do registry settings on every client machine.

The root cause is no-cache settings in response header, so I just added

Response.ClearHeaders()

before adding content to be downloaded to the response header. The code is as shown below,

Response.ClearHeaders()
Response.ContentType = corspBean.ContentType
Response.AppendHeader("content-disposition", "attachment; filename=""" + fileName + """")
Response.BinaryWrite(fileBytes)
Response.End()

It has fixed the issue.

Enjoy!!!

Upvotes: 1

uvita
uvita

Reputation: 4124

I ran into that same problem using LocalReport when exporting to excel. Just before the

Response.BinaryWrite(bytes);

we added

Response.ClearHeaders();
Response.ClearContent();
Response.Buffer = true;

and it worked.

Upvotes: 0

Eric
Eric

Reputation: 3334

Take a look at this article. It's from the horse's mouth so to speak :) We actually just faced this same issue when we switched to a full SSL session.

Upvotes: 2

Related Questions