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

sesea 2007-03-21 02:32:25
直接用代码生成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()
...全文
1011 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
jon1365 2007-03-29
  • 打赏
  • 举报
回复
在客户端IE的属性--安全项选中“下载提示”下就可以了
最后一只恐龙 2007-03-22
  • 打赏
  • 举报
回复
代码看似没问题,那个窗口是不是你自己关闭的?可能关闭时间不对。
toupapm 2007-03-22
  • 打赏
  • 举报
回复
试试这个:

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();
winsonjie 2007-03-22
  • 打赏
  • 举报
回复
这个我遇到过.可能是你的IE的问题..可能你把某些功能给禁了..换个浏览器试试

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧