110,539
社区成员
发帖
与我相关
我的任务
分享
public Action<HttpResponse, byte[]> ce;
protected void Page_Load(object sender, EventArgs e)
{
HttpResponse response = HttpContext.Current.Response;
context = HttpContext.Current;
byte[] byData = new byte[1];
ce += testAsync;
ce.BeginInvoke(response, byData, null, null);
}
private static void testAsync(HttpResponse context, byte[] byData)
{
Thread.Sleep(10000);
context.ClearContent();
context.BufferOutput = true;
context.ContentType = "application/octet-stream";
context.AddHeader("Content-Disposition", "attachment; filename=123.xls");
context.BinaryWrite(byData);
context.Flush();
context.Close();
}