ash*_*arg 2 asp.net-core-mvc asp.net-core-1.0
System.IO.StringWriter objStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter objHtmlTextWriter = new System.Web.UI.HtmlTextWriter(objStringWriter);
gv.RenderControl(objHtmlTextWriter);
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", "attachment; filename=DemoExcel.xls");
Response.ContentType = "application/ms-excel";
Response.Charset = "";
Response.Output.Write(objStringWriter.ToString());
Response.Flush();
Response.Close();
Run Code Online (Sandbox Code Playgroud)
给出错误响应不包含在 Asp.net Core 中 ClearContent 的定义
小智 6
在网上找到这个答案 https://forums.asp.net/t/1567637.aspx?Response+Clear+vs+Response+ClearContent+Response+ClearHeaders+
Response.Clear();
Response.Headers[HeaderNames.ContentDisposition] = "attachment; filename=DemoExcel.xls";
Response.WriteAsync(objStringWriter.ToString()).Wait()
Run Code Online (Sandbox Code Playgroud)
希望它可以帮助某人
| 归档时间: |
|
| 查看次数: |
3444 次 |
| 最近记录: |