response.redirect & response.end

P

postings

Just a quick question...

When I do a "response.redirect" from a source webpage to a destination
webpage, does the code on the source webpage carry on executing unless
I put a "response.end" straight the "response.redirect" command?

I know about server.transfer BTW, I just want to know what happens in
this instance...

Many thanks!

Alex
 
D

Damien

Just a quick question...

When I do a "response.redirect" from a source webpage to a destination
webpage, does the code on the source webpage carry on executing unless
I put a "response.end" straight the "response.redirect" command?

I know about server.transfer BTW, I just want to know what happens in
this instance...

Many thanks!

Alex

Look at the second argument to Response.Redirect(). It lets you choose.
If you don't supply a second argumnet, the default is to end the
response immediately.

Be aware that it terminates the current request by using a
ThreadAbortException, so if you're inside a Try/Catch/Finally then some
of your Catch code may run (depending on how specific your Catch filter
is), and your finally code will run.

Damien
 
J

JIMCO Software

Damien said:
Be aware that it terminates the current request by using a
ThreadAbortException, so if you're inside a Try/Catch/Finally then
some of your Catch code may run (depending on how specific your Catch
filter is), and your finally code will run.

The Finally code will always run regardless. ;)
 
D

Damien

JIMCO said:
The Finally code will always run regardless. ;)
Agreed. I'm guessing you felt my wording a bit ambiguous, so the OP may
have done too.

As an aside, does anyone know if the SEH/Finally code would run if the
Thread was aborted using TerminateThread()?

Cheers,

Damien
 
P

postings

Thanks guys!

Damien said:
Look at the second argument to Response.Redirect(). It lets you choose.
If you don't supply a second argumnet, the default is to end the
response immediately.

Thanks, I see the parameter now (doh!).

Can I just reconfirm here, by NOT setting an argument in
response.redirect the code will immediately halt execution of the page
it is executing from (coundn't find anything in the documentation about
the default behavior).

It's just seems my app appears to intermittently execute code after
this command sometimes (esp when clicking buttons with a redirector),
tricky thing really.

Cheers

Alex
 
J

JIMCO Software

Damien said:
As an aside, does anyone know if the SEH/Finally code would run if the
Thread was aborted using TerminateThread()?

I'm not sure. Based on the documentation on that API, I'd say that it would
not.
 
P

postings

Just in case this got missed, sorry to repost:

Can I just reconfirm here, by NOT setting an argument in
response.redirect the code will immediately halt execution of the page
it is executing from (coundn't find anything in the documentation about

the default behavior).

It's just seems my app appears to intermittently execute code after
this command sometimes (esp when clicking buttons with a redirector),
tricky thing really.

Cheers

Alex
 
J

JIMCO Software

Just in case this got missed, sorry to repost:

Can I just reconfirm here, by NOT setting an argument in
response.redirect the code will immediately halt execution of the page
it is executing from (coundn't find anything in the documentation
about

the default behavior).

Yes. Response.Redirect calls Response.End which then makes a call into the
runtime to halt execution of the current thread.
 
B

Bruce Barker

the actual code for Redirect(url) is:

public void Redirect(string url)
{
this.Redirect(url,true);
}

setting endResponse to true causes Response.End() to be called.
Response.End() just kills the current thread (in most cases).

-- bruce (sqlwork.com)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top