在开始下载之前要更新页面吗? [英] Updating a page before initiating a download?

查看:54
本文介绍了在开始下载之前要更新页面吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,允许用户输入搜索条件,然后显示匹配的记录.它还具有一个下载按钮,使用户能够下载匹配的记录.

I've got a page that allows users to enter search criteria and then display matching records. It also has a download button to enable the user to download matching records.

我该如何编码,以便单击下载"将首先刷新记录显示,然后再下载数据?

How can I code it so that clicking on "Download" will first refresh the record display before downloading the data?

这是我用于下载的代码:

This is the code that I'm using for the download:

Response.ClearContent();
Response.ClearHeaders();

using (MemoryStream outputStream = new MemoryStream())
{
    // some details elided...
    outputStream.Write(documentData, 0, documentData.Count());

    string fileName = GenerateFileName();

    Response.AppendHeader("content-disposition", String.Format("attachment; filename={0}", fileName));
    outputStream.Flush();
    outputStream.WriteTo(Response.OutputStream);
}
Response.Flush();
Response.Close();

推荐答案

只有一个响应可以发送回浏览器,以太坊将更新数据,以太坊将发送新的标头以开始下载.

Only one response you can send back to the browser, ether you update the data, ether you send the new header to start the download.

要同时创建它们,您可能需要使用一些javascript和/或ajax调用来更改步骤.

To make both of them you need to change your steps probably using some javascript and/or ajax call.

HTTP协议的工作方式: http://www.w3.org/Protocols/rfc2616/rfc2616-sec1.html

How HTTP protocol works: http://www.w3.org/Protocols/rfc2616/rfc2616-sec1.html

这篇关于在开始下载之前要更新页面吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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