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.
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 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
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.
Ennair
Member
32 Points
207 Posts
Response.TransmitFile stops rest of page execution
Nov 12, 2010 07:12 PM|LINK
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.
qwe123kids
All-Star
48619 Points
7957 Posts
MVP
Re: Response.TransmitFile stops rest of page execution
Nov 13, 2010 10:00 AM|LINK
Hi,
Is Size of file is very large?
Avinash Tiwari
Remember to click “Mark as Answer” on the post, if it helps you.
Ennair
Member
32 Points
207 Posts
Re: Response.TransmitFile stops rest of page execution
Nov 13, 2010 01:15 PM|LINK
It's 2.59MB
qwe123kids
All-Star
48619 Points
7957 Posts
MVP
Re: Response.TransmitFile stops rest of page execution
Nov 13, 2010 02:53 PM|LINK
have tried donwlaoding File less then 1 mb?
Avinash Tiwari
Remember to click “Mark as Answer” on the post, if it helps you.
Ennair
Member
32 Points
207 Posts
Re: Response.TransmitFile stops rest of page execution
Nov 13, 2010 05:48 PM|LINK
The one I have currently downloads fine. It just stops code execution after the download.
Ennair
Member
32 Points
207 Posts
Re: Response.TransmitFile stops rest of page execution
Nov 16, 2010 10:53 AM|LINK
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
qwe123kids
All-Star
48619 Points
7957 Posts
MVP
Re: Response.TransmitFile stops rest of page execution
Nov 16, 2010 11:19 AM|LINK
Not very sure
Response.Flush();
Response.Close();
Response.End()
have tried using after Transmit file?
Avinash Tiwari
Remember to click “Mark as Answer” on the post, if it helps you.
Ennair
Member
32 Points
207 Posts
Re: Response.TransmitFile stops rest of page execution
Nov 16, 2010 11:56 AM|LINK
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?
ptiso
Member
2 Points
2 Posts
Re: Response.TransmitFile stops rest of page execution
Aug 18, 2011 03:48 PM|LINK
Hello, i know this post is old but I wanted to know if you find any solution for this problem :(
Thanks !