.NETGURU
frustration with events firing
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.aspnet.

Post a new message to this list...

Rob
ok, so im ready to absolutely throw my self right into the monitor,
can anyone explain why certain events fire before others in asp.net?
in my case, after some processing a final download aspx page calls a
download function which writes a file to the browser.. yet after that
is done I want the page to redirect to another page, but no matter
what I try it wont redirect, I know there is something with the way
..net works, I just cant figure it out.

here is simplified version of code

process....
call downloadfile

Sub downloadfile (fullfile as string)
Dim fstream As FileStream = File.Open(fullfile,
FileMode.Open)
Dim fsize As Long = fstream.Length
Dim Buffer(CInt(fsize)) As Byte
fstream.Read(Buffer, 0, CInt(fsize))
fstream.Close()
Response.AddHeader("content-disposition", "attachment;
filename=" + filename)
Response.BinaryWrite(Buffer)
Response.Redirect("main.aspx")<--- this does not fire at
all?
end sub

after the open/save window comes up , the redirect never fires..
thoughts appreciated.
Reply to this message...
 
    
Hermit Dave
you are sending the file to the user and you need to finish the current
request before the client can make another request. in this case user
Response.Redirect (it executes from client browser) and since the client is
still not done with the last request.. nothing will happen.

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Rob" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
bruce barker
your approach will not work. you can not return content and redirect in the
same response.

redirect works by sending a special header with a redirect url. if the
browser sees this header, it loads the url. in your code you are sending a
response, then sending a header which the browser will never see.

-- bruce (sqlwork.com)

"Rob" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Rob
thank you all for your thoughts.
so how would you do this then? how can you send the file to the
browser, and have the page redirect, or do any other activity AFTER
the file has been written to browser?

"bruce barker" <Click here to reveal e-mail address> wrote in message news:<OsqO$Click here to reveal e-mail address>...
[Original message clipped]

Reply to this message...
 
    
Hermit Dave
you cant thats why most people send the file over using a new window.
ie use a button or a hyperlink with target as _blank and then send the
request for the aspx page that sends the file.
ie its a content type that cannot be open by the browser then it will keep
the user on current page.. but thats about all you can do.

if you find a work around do let me know...
--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Rob" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
    
Kevin Spencer
I keep a copy of the following article taped to my wall:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconControlExecutionLifecycle.asp

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Rob" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.IO.File
System.IO.FileMode
System.IO.FileStream




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification