如何使用ASP.NET C#立即执行下载? [英] How to perform a download instantly with ASP.NET C#?

查看:167
本文介绍了如何使用ASP.NET C#立即执行下载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们必须下载一个相当大的数据量。

We have a rather large amount of data to be downloaded.

目前我们的系统只是输出流(我们不使用文件)

Currently our system just outputs the stream (we do not use files)

code:


         HttpContext.Current.Response.AppendHeader("content-disposition", String.Format("attachment; filename={0}", filename));
            HttpContext.Current.Response.BinaryWrite(ms.ToArray());

            HttpContext.Current.Response.End();

然而,它使用的是服务器上的大量的内存量,等待下载的文件。我想打它,所以它开始下载立即而不是等待......我怎样才能做到这一点?

However, it is using an extensive amount of memory on the server, waiting for the file to download.. I'd like to make it so it starts to download immediately rather than waiting... How can I do this?

推荐答案

尝试设置这样的:

HttpContext.Current.Response.BufferOutput = false;

这篇关于如何使用ASP.NET C#立即执行下载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆