关于文件下载的问题,请思归看一下!!

ahking 11 11  2003-12-12 05:20:13
1、Response.OutputStream.Write和BinaryWrite有什么区别
2、Response.ContentType = "application/octet-stream";在下载时是必须的么?
3、我在一个帖子上看过你说过下面的话:
it is a bad idea to return the downloaded file in the current page's button handler, you should use a popup page, but try to call

Response.Clear()
Response.ClearHeaders()

how to use a popup page,there too many data,transfer them to the new page?how to do it?



...全文
11 9 打赏 收藏 举报
写回复
9 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
ahking 2003-12-14
????
  • 打赏
  • 举报
回复
ahking 2003-12-13
在Response.End()之前应该关闭数据库连接吧!
  • 打赏
  • 举报
回复
ahking 2003-12-13
there is another question,in some client,the file is always save as html,why??
  • 打赏
  • 举报
回复
ahking 2003-12-13
help
  • 打赏
  • 举报
回复
ken2003 2003-12-13
up
  • 打赏
  • 举报
回复
ahking 2003-12-13
还有个更怪的问题:
整个页面为框架网页,分top和main,当下载文件后(下载页面在框架网页的mian页面),原先可用的top上的连接(链接到main)都不可用了,怎么回事??
  • 打赏
  • 举报
回复
saucer 2003-12-12
1. OutputStream is the raw stream to output the content to the client side, you can customize your output by chaining other stream writers

Response.BinaryWrite, I believe, is for backward compatibility with ASP, it could be using this stream directly , but I have no idea, since I don't have access to the source code

2. this content type is normally used when you don't want the browser to open a program registered for the specific content-type/file extension

3. what I meant was,

<asp:Button runat=server text="download" Onclick="DownloadFile" />

runs in the context of current page, if you don't call

Response.Clear()
Response.ClearHeaders()
...

Response.End()

in your DownloadFile method, some garbage content will also be written to the downloaded file, and it is also odd to embed the download logic inside the current page too

you should be using something like
<a href="download.aspx?id=123">download</a>

it is cleaner and more maintainable


for download huge amount of data, look into

Streaming Files Efficiently Using HTTPHandler and ISAPI
http://www.dotnetjunkies.com/Article/E9BE4431-3561-4A64-88C8-A49B2E50CBFA.dcik
  • 打赏
  • 举报
回复
cm8983 2003-12-12
up
  • 打赏
  • 举报
回复
ahking 2003-12-12
up
  • 打赏
  • 举报
回复
相关推荐
发帖
.NET社区
加入

6.0w+

社区成员

.NET技术交流专区
帖子事件
创建了帖子
2003-12-12 05:20
社区公告

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

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