Question about Response.Redirect

Discussion in 'ASP General' started by JC, Jun 8, 2004.

  1. JC

    JC Guest

    Hi,

    I have a simple question regarding the Response.Redirect method. Does the
    server stop processing the ASP code as soon as it encounters the Redirect
    command? Or does it ever continue to process the page?

    Basically, with the following code:

    [....]
    Response.Redirect("../newpage.asp")
    Response.Write "This will crash: " & 1/0

    It seems that the server sends the redirection header to the client as soon
    as it hits the .Redirect line, and stops processing that page. I do not
    receive a divide by zero error.

    Is this always the expected behavior?

    Also, someone mentioned in a previous thread that the correct syntax to use
    is

    Response.Redirect "http://someurl.com"
    Response.End

    What would happen if someone omitted to send a Response.End command?

    Thanks in advance.

    JC
     
    JC, Jun 8, 2004
    #1
    1. Advertising

  2. JC

    Mike Guest

    in your first code snippet the response.write will never execute because the
    page is redirected. it will always work like that. As for the second snippet
    if you have response.end or not after a redirect doesn't matter. The
    redirect will still execute

    "JC" <> wrote in message
    news:...
    > Hi,
    >
    > I have a simple question regarding the Response.Redirect method. Does the
    > server stop processing the ASP code as soon as it encounters the Redirect
    > command? Or does it ever continue to process the page?
    >
    > Basically, with the following code:
    >
    > [....]
    > Response.Redirect("../newpage.asp")
    > Response.Write "This will crash: " & 1/0
    >
    > It seems that the server sends the redirection header to the client as

    soon
    > as it hits the .Redirect line, and stops processing that page. I do not
    > receive a divide by zero error.
    >
    > Is this always the expected behavior?
    >
    > Also, someone mentioned in a previous thread that the correct syntax to

    use
    > is
    >
    > Response.Redirect "http://someurl.com"
    > Response.End
    >
    > What would happen if someone omitted to send a Response.End command?
    >
    > Thanks in advance.
    >
    > JC
    >
    >
     
    Mike, Jun 8, 2004
    #2
    1. Advertising

  3. JC

    Steven Burn Guest

    http://aspfaq.com/show.asp?id=2217
    http://aspfaq.com/show.asp?id=2011

    --

    Regards

    Steven Burn
    Ur I.T. Mate Group
    www.it-mate.co.uk

    Keeping it FREE!


    "JC" <> wrote in message
    news:...
    > Hi,
    >
    > I have a simple question regarding the Response.Redirect method. Does the
    > server stop processing the ASP code as soon as it encounters the Redirect
    > command? Or does it ever continue to process the page?
    >
    > Basically, with the following code:
    >
    > [....]
    > Response.Redirect("../newpage.asp")
    > Response.Write "This will crash: " & 1/0
    >
    > It seems that the server sends the redirection header to the client as

    soon
    > as it hits the .Redirect line, and stops processing that page. I do not
    > receive a divide by zero error.
    >
    > Is this always the expected behavior?
    >
    > Also, someone mentioned in a previous thread that the correct syntax to

    use
    > is
    >
    > Response.Redirect "http://someurl.com"
    > Response.End
    >
    > What would happen if someone omitted to send a Response.End command?
    >
    > Thanks in advance.
    >
    > JC
    >
    >
     
    Steven Burn, Jun 8, 2004
    #3
  4. JC

    Steven Burn Guest

    I was always told to stick Response.End after it (never told why mind).....?

    --

    Regards

    Steven Burn
    Ur I.T. Mate Group
    www.it-mate.co.uk

    Keeping it FREE!


    "Mike" <> wrote in message
    news:...
    > in your first code snippet the response.write will never execute because

    the
    > page is redirected. it will always work like that. As for the second

    snippet
    > if you have response.end or not after a redirect doesn't matter. The
    > redirect will still execute
    >
    > "JC" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > I have a simple question regarding the Response.Redirect method. Does

    the
    > > server stop processing the ASP code as soon as it encounters the

    Redirect
    > > command? Or does it ever continue to process the page?
    > >
    > > Basically, with the following code:
    > >
    > > [....]
    > > Response.Redirect("../newpage.asp")
    > > Response.Write "This will crash: " & 1/0
    > >
    > > It seems that the server sends the redirection header to the client as

    > soon
    > > as it hits the .Redirect line, and stops processing that page. I do not
    > > receive a divide by zero error.
    > >
    > > Is this always the expected behavior?
    > >
    > > Also, someone mentioned in a previous thread that the correct syntax to

    > use
    > > is
    > >
    > > Response.Redirect "http://someurl.com"
    > > Response.End
    > >
    > > What would happen if someone omitted to send a Response.End command?
    > >
    > > Thanks in advance.
    > >
    > > JC
    > >
    > >

    >
    >
     
    Steven Burn, Jun 8, 2004
    #4
  5. JC

    JC Guest

    That's wonderful, this first link contained all the information I could wish
    for.

    Cheers,

    JC


    "Steven Burn" <> wrote in message
    news:...
    > http://aspfaq.com/show.asp?id=2217
    > http://aspfaq.com/show.asp?id=2011
    >
    > --
    >
    > Regards
    >
    > Steven Burn
    > Ur I.T. Mate Group
    > www.it-mate.co.uk
    >
    > Keeping it FREE!
    >
    >
    > "JC" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > I have a simple question regarding the Response.Redirect method. Does

    the
    > > server stop processing the ASP code as soon as it encounters the

    Redirect
    > > command? Or does it ever continue to process the page?
    > >
    > > Basically, with the following code:
    > >
    > > [....]
    > > Response.Redirect("../newpage.asp")
    > > Response.Write "This will crash: " & 1/0
    > >
    > > It seems that the server sends the redirection header to the client as

    > soon
    > > as it hits the .Redirect line, and stops processing that page. I do not
    > > receive a divide by zero error.
    > >
    > > Is this always the expected behavior?
    > >
    > > Also, someone mentioned in a previous thread that the correct syntax to

    > use
    > > is
    > >
    > > Response.Redirect "http://someurl.com"
    > > Response.End
    > >
    > > What would happen if someone omitted to send a Response.End command?
    > >
    > > Thanks in advance.
    > >
    > > JC
    > >
    > >

    >
    >
     
    JC, Jun 8, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Charles A. Lackman
    Replies:
    2
    Views:
    8,020
    Charles A. Lackman
    Jan 11, 2006
  2. Matthew Wieder

    Response.Write and Response.Redirect

    Matthew Wieder, Jul 17, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    706
    Kevin Spencer
    Jul 17, 2003
  3. =?Utf-8?B?VHJveQ==?=

    Response.redirect does not redirect from .aspx page

    =?Utf-8?B?VHJveQ==?=, Oct 18, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    5,260
    Srowe1975
    Oct 15, 2008
  4. Sal
    Replies:
    1
    Views:
    538
  5. Ron Howard
    Replies:
    2
    Views:
    528
    Ron Howard
    Aug 11, 2004
Loading...

Share This Page