Thursday, December 10, 2009

asp.net export to txt file receive error in IE when hosted in IIS6

code:

"Response".Clear();
"Response".AddHeader("content-disposition", "attachment;filename=" + FileName + ".txt");
"Response".Charset = "";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
"Response".ContentType = "application/vnd.text";
"StringWriter" stringWrite = new StringWriter();
"HtmlTextWriter" htmlWrite = new HtmlTextWriter(stringWrite);
"Response".Write(strTXTFileBuilder.ToString());
"Response".End();

Error:
Internet Explorer cannot download file from .
Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.

My Solution:
Take out the line "
"Response".Cache.SetCacheability(HttpCacheability.NoCache);"

No comments: