I've just spent quite a while debugging a problem with content disposition I was having with Internet Explorer 7, the code works fine in Firefox but causes this error message to occur in IE7.
"Internet Explorer cannot download xxx from xxx."
"Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later."
This was my original snippet of C# code:
Response.Buffer = true;
Response.ContentType = docToDisplay.Type.ContentType.ToString();
Response.AddHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(docToDisplay.FileName));
I eventually figured out that the following line on code was causing the issue.
I then did a quick search for "Response.Cache.SetCacheability(HttpCacheability.NoCache);" and discovered another developer who have had the same Content-Disposition issue. Unfortunately for me that page didn't get returned when I was searching for the Internet Explorer error message.
This was the response to the post by Microsoft Online Support:
"Yes, the exporting code you provided is standard one and after some further
testing, I think the problem is just caused by the httpheader set by
I just captured the http messages when setting and not setting the above
"NOCache" option and found that when the http response returned the
header. So we can also reproduce the problem when using the following code:
Response.CacheControl = "no-cache";
IMO, this should be the clientside browser's behavior against "no-cache"
response with stream content other than the original text/html content. So
would you try avoid setting the CacheAbility or the "Cache-Control" header
to "no-cache" when you'd like to output custom binary file stream?
Microsoft Online Support"
After removing the Response.Cache.SetCacheability line the file downloads correctly in Internet Explorer.