locked
Response.TransmitFile stops rest of page execution RRS feed

  • Question

  • User-544655287 posted

    Hi

    i am trying to have a download on my page. I have implemented the code below but code execution stops after the download message pops up, even if i press save or cancel, nothing happens after that.


    Response.Clear();
                Response.AddHeader("Content-Disposition", "attachment; filename=" + lFile.Name);
                Response.AddHeader("Content-Length", lFile.Length.ToString());
                Response.ContentType = "application/octet-stream";
                Response.TransmitFile(lFile.FullName);
                Response.End();


    I have tried it a few times without Response.Clear() and Response.End() but it didn't make any difference to take these off. Is there anyway I can achieve this without having to using an IFrame?

    Any suggestions will be very much appreciated.

    Friday, November 12, 2010 3:12 PM

All replies

  • User-1659704165 posted

    Hi,

    Is Size of file is very large?

    Saturday, November 13, 2010 6:00 AM
  • User-544655287 posted

    It's 2.59MB

    Saturday, November 13, 2010 9:15 AM
  • User-1659704165 posted

    have tried donwlaoding File less then 1 mb?

    Saturday, November 13, 2010 10:53 AM
  • User-544655287 posted

    The one I have currently downloads fine. It just stops code execution after the download.

    Saturday, November 13, 2010 1:48 PM
  • User-544655287 posted

    Any suggestions on this one please? I don't understand why the page execution doesn't continue after the download. There is only a label that's assigned some text to its Text property before the download has been initiated but the text never shows up because the download stops that.

    It looks like no matter where in the code I add the custom HTTP headers for downloading the file, the download will start before the Label's text shows on the screen. They are both in the same

    Tuesday, November 16, 2010 6:53 AM
  • User-1659704165 posted

    Not very sure

    Response.Flush();
    Response.Close();
    Response.End()

    have tried using after Transmit file?


    Tuesday, November 16, 2010 7:19 AM
  • User-544655287 posted

    i have done that. I don't think that's the problem, it seems like the response will end anyway after the download dialogue pops up so anything that still hasn't been written to the screen is halted.


    Any one else with suggestions to this please?


    Tuesday, November 16, 2010 7:56 AM
  • User-836640726 posted

    Hello, i know this post is old but I wanted to know if you find any solution for this problem :(

    Thanks ! 

    Thursday, August 18, 2011 11:48 AM