3
我生成從DataGrid一個CSV和使用下面的代碼下載它:還包含HTML代碼
var context = HttpContext.Current;
context.Response.ClearHeaders();
context.Response.ContentType = "application/vnd.ms-excel";
context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename);
context.Response.Write(csvString);
Response.Flush();
的CSV下載,但它下面,還有的html標籤這一頁。有什麼可能是錯的?
Thanx Nunepascal.Another問題雖然是response.end()停止執行任何代碼後,任何想法如何繞過? –
好吧,這個想法是在這之後停止代碼,這樣你就不會渲染其他東西。響應結束後需要執行哪些代碼?有些方法可以在'Response.End'之後執行代碼,但它通常會暗示其他錯誤。 – nunespascal