Start download in separate Response

  • Thread starter Thread starter hoenes1
  • Start date Start date
H

hoenes1

Hi,

in my ASP.NET App, I have a list of files which the user can download
on click (using Response.BinaryWrite()). the problem is, that once a
download has started, the user can't navigate in the window because
the response is sending the file and so no new requests can be made.
what possibilities do i have to make the client able to browse other
pages in my app while downloading a file?
Thanks in advance.
 
have the call open a second window (with clientside event) and pass the
filename to it, This window can do the write then.

Curt
 
Thanks. Sounds good, but could you post a code sample please? I'm not
sure what you mean by "clientside event".
Thanks again in advance.
 
hoenes1 said:
*Hi,

in my ASP.NET App, I have a list of files which the user ca
download
on click (using Response.BinaryWrite()). the problem is, that once a
download has started, the user can't navigate in the window because
the response is sending the file and so no new requests can be made.
what possibilities do i have to make the client able to browse other
pages in my app while downloading a file?
Thanks in advance. *

I saw this piece of code, using the Response.Write in the same page
and did not experience any problem, hope that it could help you.

where strPath is the path of the file you want to allow the user t
download.

Dim path As String = Server.MapPath(strPath)
Dim file As IO.FileInfo = New IO.FileInfo(path)

If file.Exists Then
Response.Clear()
Response.AddHeader("Content-Disposition", "attachment;filename="
file.Name)
Response.AddHeader("Content-Length", file.Length.ToString())
Response.ContentType = "application/octet-stream"
Response.WriteFile(file.FullName)
Response.End()
End I


-
weichun
 
Weichung,

thanks for your post, but your code is virtually the same as mine. The
problem is that the Response that you use to send the file
(Response.Write()) is blocked while the file is sent to the client.
Right after the last byte is written to the client, the next line in
your code (Response.End()) is called. My problem is that I want to
continue browsing during a long download (>100 MB). In your case, the
Response is blocked until the file is sent, meaning that no further
request can be made from the same client until the download is
finished. I considered the possibility of creating another ASP.NET
application which is only responsible for sending the file. But is
that the common way?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top