I recently had a problem while trying to download a file that was being generated dynamically from an ASP.NET application.
This was being done the following way:
Response.Clear();
Response.AddHeader("content-disposition", "attachment; filename=EXAMPLE.bin");
Response.AddHeader("Content-Transfer-Encoding", "binary");
Response.AddHeader("Content-Length", /* The length */);
Response.ContentType = "/*Wanted content type*/";
Response.OutputStream.Write(/* Your File */);
Response.Flush();
Response.End();
When you run this code this will work perfectly for Firefox and IE, allowing you to download the generated file.
However, once you enable SSL encryption on this website, you will get to following error message in Internet Explorer :
Internet Explorer cannot download <PAGENAME> from <SERVERNAME> .
Internet Explore was not able to open this Internet Site. The requested site is either unavailable or cannot be found. Please try again later.
You can fix this problem by adding the following line above your header definitions.
Response.ClearContent();
Response.ClearHeaders();
This way the request headers will be set correctly and you will be able to download your file from your SSL encrypted website.
No comments:
Post a Comment