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

ahking 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?



...全文
41 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
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

62,243

社区成员

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

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

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

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