Response文件流下载文件,在IE中一闪而过不提示保存
直接用代码生成excel文件编码,希望通过文件流的方式输出,不在服务器上生成物理文件。
在Maxthon2中就可以正常保存,但在IE6中,虽然有窗口弹出却没有提示保存为本地文件,代码如下:
Dim OutStr As New System.Text.StringBuilder
Response.Clear()
Response.Buffer = True
Response.Charset = "GB2312 "
Response.AppendHeader( "Content-Disposition ", "attachment;filename=mcdatamdx.xls ")
Response.Output.Write(OutStr.ToString)
Response.Flush()
Response.End()
------解决方案--------------------这个我遇到过.可能是你的IE的问题..可能你把某些功能给禁了..换个浏览器试试
------解决方案--------------------试试这个:
HttpContext.Current.Response.AppendHeader( "Content-Disposition ", "attachment;filename=Excel.xls ");
HttpContext.Current.Response.Charset = "UTF-8 ";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Default;
HttpContext.Current.Response.ContentType = "application/ms-excel ";
dg.Page.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
dg.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.Flush();
------解决方案--------------------在客户端IE的属性--安全项选中“下载提示”下就可以了