Asp.net is used to automatically generate a TXT text file based on the data content and provide users with download. This method is not saved on the server and is directly provided to users for download, response. binarywrite (), used a few times, found that there is a problem in IE, look at the pageSource codeThe data is generated. In Firefox, a box is displayed to download the data, but not txt, but Aspx. The content in the box is the data obtained from the database.
In fact, you can simply use write () in ASP. NET,CodeAs follows (. aspx. CS file ):
Response. Clear ();
Response. Buffer = false;
Response. contenttype = "application/octet-stream ";
Response. appendheader ("content-disposition", "attachment; filename =" + filename + ". txt ;");
Response. Write ("1234 | ABCDE \ r \ n ");
// Read the database, loop
For (I = 0; I <100; I ++)
{
Response. Write ("1234 | ABCDE \ r \ n ");
}
Response. Flush ();
Response. End ();
Both IE and Firefox
Http://www.the9web.com/blog/2009/09/07/175/
From: http://qingtiansunsky.blog.163.com/blog/static/95006479201023004134905/