P
ProJee
Hi,
Response.WriteFile (or Response.OutputStream.Write) finishes
immediately, not after the file is completely downloaded.
It finishes before (!) the user clicks the "Save" or "Open" browser
button, file size doesn't matter. I'm not possible to track if the file
was completely downloaded or if the user only clicked the link and
cancelled the download.
I've created a simple "solution" of this problem, which waits until the
user clicks "Cancel" or "Open".
Two things to solve:
When the user clicks "Save", IsClientConnected remains true until
the user closes browser window... (Navigation to another page doesn't
close the connection.)
Moreover, I don't know how to read an information about whether the file
was fully downloaded or not. Something like
Response.TotalBytesThatReallyArrivedToTheUser..
thanks
ProJee
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim path As String = "c:\file.mp3"
Response.ClearHeaders()
Response.ClearContent()
Response.Clear()
Response.Buffer = False
Response.BufferOutput = False
Response.AddHeader("Content-Disposition",
"attachment;filename=file.mp3")
Response.AppendHeader("Content-Length", FileLen(path))
Response.ContentType = "image/jpg"
Dim bytesToGo As Integer
Dim bytesRead As Integer
Dim fStream
Dim byteBuffer
Response.WriteFile("c:\file.mp3", False)
Do
Threading.Thread.Sleep(100)
Loop While Response.IsClientConnected
'it comes here AFTER the connection is broken ("Open", "Cancel" 'or
browser exit after "Save") which is great, but I don't know 'if the
file was downloaded; to detect user action.
Response.End()
End Sub
Response.WriteFile (or Response.OutputStream.Write) finishes
immediately, not after the file is completely downloaded.
It finishes before (!) the user clicks the "Save" or "Open" browser
button, file size doesn't matter. I'm not possible to track if the file
was completely downloaded or if the user only clicked the link and
cancelled the download.
I've created a simple "solution" of this problem, which waits until the
user clicks "Cancel" or "Open".
Two things to solve:
When the user clicks "Save", IsClientConnected remains true until
the user closes browser window... (Navigation to another page doesn't
close the connection.)
Moreover, I don't know how to read an information about whether the file
was fully downloaded or not. Something like
Response.TotalBytesThatReallyArrivedToTheUser..
thanks
ProJee
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim path As String = "c:\file.mp3"
Response.ClearHeaders()
Response.ClearContent()
Response.Clear()
Response.Buffer = False
Response.BufferOutput = False
Response.AddHeader("Content-Disposition",
"attachment;filename=file.mp3")
Response.AppendHeader("Content-Length", FileLen(path))
Response.ContentType = "image/jpg"
Dim bytesToGo As Integer
Dim bytesRead As Integer
Dim fStream
Dim byteBuffer
Response.WriteFile("c:\file.mp3", False)
Do
Threading.Thread.Sleep(100)
Loop While Response.IsClientConnected
'it comes here AFTER the connection is broken ("Open", "Cancel" 'or
browser exit after "Save") which is great, but I don't know 'if the
file was downloaded; to detect user action.
Response.End()
End Sub