How to redirect output back to browser after Response.WriteFile download???

Discussion in 'ASP .Net' started by Earl Teigrob, Jan 20, 2004.

  1. Earl Teigrob

    Earl Teigrob Guest

    I have a datagrid with a download button that raises the itemcommand event.
    In the event handler for this event, I have the code below. The problem is
    that the download code requires a Response.End() in order to stop further
    output the the response stream(such as the posted back page itself). Is
    there a way to divert the output stream back to the browser after the file
    has downloaded without using a Response.End() (which ends all page
    processing) ???

    If I can find that, then the postback can occure and my databindgrid will
    work and everything is fixed!

    Thanks in Advance

    Earl

    .....
    dl.UpdateDownloadDate(pkDownloadMaster,System.DateTime.Now);

    DataBindGrid(dl.SelectOrderNo(pkDownloadMaster));

    string filename= "downloadfile.txt";

    string filepath = Page.MapPath(".") + "\\" + filename;

    Response.Clear();

    Response.ContentType = "application/octet-stream";

    Response.AddHeader("Content-Disposition", "attachment; filename=\"" +
    filename + "\"");

    Response.WriteFile(filepath);

    Response.End();
     
    Earl Teigrob, Jan 20, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Q2FydGVy?=

    Postback after a Response.Writefile()

    =?Utf-8?B?Q2FydGVy?=, Feb 18, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    10,404
    dmcmillan
    Oct 9, 2009
  2. Ryan Pedersen
    Replies:
    1
    Views:
    2,216
    Daniel Fisher\(lennybacon\)
    Jul 12, 2005
  3. Jonathan
    Replies:
    0
    Views:
    2,917
    Jonathan
    Sep 20, 2006
  4. Khafancoder
    Replies:
    5
    Views:
    507
    Khafancoder
    Aug 15, 2007
  5. Sal
    Replies:
    1
    Views:
    822
Loading...

Share This Page