c# - 确认文件已下载

标签 c# asp.net .net

有没有办法确认用户已经下载了文件? (与拒绝下载或中途取消下载相反?)最好在 c# 代码隐藏中。

使用时:Response.Write(...); .

最佳答案

您可以使用 Response.IsClientConnected 来检查客户端是否仍然连接。

来自MSDN

This property enables you greater control over circumstances where the client may have reset the connection to the server. For example, if a long period of time has elapsed between when a client request was made and when the server responded, it may be beneficial to make sure the client is still connected before continuing to process the script.

在使用 Response.Write 写入响应后,执行此命令以检查客户端是否已连接,如果为真则表示文件已写入响应/已下载。

http://msdn.microsoft.com/en-us/library/ms525453(v=vs.90).aspx

关于c# - 确认文件已下载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27018214/

相关文章:

c# - 如何将方程式转换为单个变量的公式?

c# - 如何从 TestContext 获取当前参数值?

c# - 是否可以将额外的自定义用户数据传递给自定义 ASP.NET 成员资格提供程序?

c# - 如何告诉 ASP.NET 不要在请求中插入控件的值?

c# - 在值/文本更改服务器端后从文本框中获取文本/值

c# - 如何为静态变量分配内存?

c# - 在 Xamarin.android 中创建搜索函数来查询 Microsoft Azure 表记录

c# - 如何在 C# 和非托管 C++ 库之间传递对指针的引用?

c# - 如何在没有 ASP.NET Core 的情况下将 Json 数据从 Controller 发送到 javascript?

c# - C#中图像到字节数组的相对路径