Groups | Blog | Home
all groups > asp.net > may 2005 >

asp.net : Detect File is Completely Download by Client


Marina
5/18/2005 11:57:28 AM
You can't. Once the file is sent, you have no way of knowing how long it
travels over the web, or how slow the other person's connection is, or how
long it takes. Once you send it, your job is done.

[quoted text, click to view]

Marina
5/18/2005 12:56:50 PM
His code wasn't doing that. Presumably he wanted to know if there was a way
to check that after executing that piece of code. He's got to rewrite that
block of code first.

[quoted text, click to view]

Bruce Barker
5/18/2005 5:21:25 PM
this has the minor hole, that the last write may not be received by the
client even though the server successfully sent it..

-- bruce (sqlwork.com)


[quoted text, click to view]

Matt Dockerty
5/18/2005 5:30:36 PM
[quoted text, click to view]

Um, wrong, you don't just chuck a file onto the Internet and hope it reaches
it's destination. A stateful connection takes place.

There is a solution. You could send it about 512 bytes a time with
Response.BinaryWrite / Response.Flush and check for
Response.IsClientConnected between each block. If that is ever false, the
connection has dropped and the user doesn't have their file.

--
Matt

[quoted text, click to view]

RC
5/18/2005 11:25:45 PM
how to detect file is completely downloaded from client by following code?

<%@ Page language="C#" debug="true" %>
<script language="C#" runat="server">
private void Page_Load(object sender, System.EventArgs e) {
Response.ContentType="application/zip";
Response.AppendHeader("Content-Disposition","attachment;
filename=myzipfile.zip");
Response.WriteFile(@"c:\inetpub\wwwroot\myzipfile.zip");
Response.Flush();
}
</script>

Matt Dockerty
5/19/2005 10:01:29 AM
[quoted text, click to view]

HTTP 1.1 has persistent connections where the connection remains open for a
little while after the file is recieved in case the client wants something
else from the server. Unless the client needs to talk in HTTP 1.0 (extremely
rare) or you're explicitly sending a 'Connection: close' header the last
block will be detected too.

[quoted text, click to view]
<snip>

AddThis Social Bookmark Button