开发者

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. Pleas开发者_开发知识库e 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?


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.


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!!!


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).


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜