With ASP. Automatically generate a txt text file according to the data content and provide user download, this method file does not protect the existence of the server, directly to the user to download, to search the Internet, are used Response.BinaryWrite (), with a few, found that there are problems in IE, Look at the page source code data is out, Firefox is a pop-up box to download, but not txt, but ASPX, inside the content is extracted from the database data.
In fact, you can use write () directly in ASP. The code is as follows (MVC 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 database, loop
for (i=0;i<100;i++)
{
Response.Write ("1234| Abcde\r\n ");
}
Response.Flush ();
Response.End ();
return new Emptyresult ();
Through IE and Firefox debugging
MVC C # Direct Export TXT file