首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

Response资料流下载文件,在IE中一闪而过不提示保存

2011-12-26 
Response文件流下载文件,在IE中一闪而过不提示保存直接用代码生成excel文件编码,希望通过文件流的方式输出

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的属性--安全项选中“下载提示”下就可以了

热点排行