Search:
Namespaces
Discussions
.NET v1.1
Feedback
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
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com