Response.Redirect causes an exeception

Discussion in 'ASP .Net' started by Waldy, Nov 15, 2007.

  1. Waldy

    Waldy Guest

    Hi there,
    I have a very simple three page web application that I am
    having trouble with. If there are any problems with any of the parameters
    that are passed to the first page, I want to redirect to an error page and
    display a message. However, when I call Response.Redirect, I get an
    exception "Thread was being aborted". I have set the EndResponse parameter
    set to true. The first page does not actually have any output, could that
    be something to do with it?

    Thanks.
     
    Waldy, Nov 15, 2007
    #1
    1. Advertising

  2. There's nothing wrong. When the response redirects, it aborts the processing
    of the first page and sends the 302 redirect to the browser. That's normal
    and prevents the first page from going on it's merry way.


    --

    Hope this helps,
    Mark Fitzpatrick
    Microsoft MVP - Expression

    "Waldy" <> wrote in message
    news:...
    > Hi there,
    > I have a very simple three page web application that I am
    > having trouble with. If there are any problems with any of the parameters
    > that are passed to the first page, I want to redirect to an error page and
    > display a message. However, when I call Response.Redirect, I get an
    > exception "Thread was being aborted". I have set the EndResponse
    > parameter set to true. The first page does not actually have any output,
    > could that be something to do with it?
    >
    > Thanks.
    >
     
    Mark Fitzpatrick, Nov 15, 2007
    #2
    1. Advertising

  3. Waldy

    Waldy Guest

    "Mark Fitzpatrick" <> wrote in message
    news:%...
    > There's nothing wrong. When the response redirects, it aborts the
    > processing of the first page and sends the 302 redirect to the browser.
    > That's normal and prevents the first page from going on it's merry way.


    Hi Mark,
    so I cannot call Response.Redirect in a try catch block?

    Regards,

    Waldy.
     
    Waldy, Nov 15, 2007
    #3
  4. Mark Rae [MVP], Nov 15, 2007
    #4
  5. Waldy

    Aidy Guest

    This situation can cause issues when you have a redirect inside a try block
    though. At least I think that's the issue.

    "Mark Fitzpatrick" <> wrote in message
    news:%...
    > There's nothing wrong. When the response redirects, it aborts the
    > processing of the first page and sends the 302 redirect to the browser.
    > That's normal and prevents the first page from going on it's merry way.
    >
    >
    > --
    >
    > Hope this helps,
    > Mark Fitzpatrick
    > Microsoft MVP - Expression
    >
    > "Waldy" <> wrote in message
    > news:...
    >> Hi there,
    >> I have a very simple three page web application that I am
    >> having trouble with. If there are any problems with any of the
    >> parameters that are passed to the first page, I want to redirect to an
    >> error page and display a message. However, when I call
    >> Response.Redirect, I get an exception "Thread was being aborted". I have
    >> set the EndResponse parameter set to true. The first page does not
    >> actually have any output, could that be something to do with it?
    >>
    >> Thanks.
    >>

    >
    >
     
    Aidy, Nov 15, 2007
    #5
  6. Waldy

    Waldy Guest

    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "Waldy" <> wrote in message
    > news:%23J%...
    > You can, but the "usual" way is to use the boolean overload:
    > http://msdn2.microsoft.com/en-us/library/a8wa7sdt(vs.80).aspx


    I am using the parameter, but set to true. What is the default if it is not
    specfied?
     
    Waldy, Nov 15, 2007
    #6
  7. Waldy

    Waldy Guest

    "Mark Rae [MVP]" <> wrote in message
    news:...
    > "Waldy" <> wrote in message
    > news:%23J%...
    >
    >> so I cannot call Response.Redirect in a try catch block?

    >
    > You can, but the "usual" way is to use the boolean overload:
    > http://msdn2.microsoft.com/en-us/library/a8wa7sdt(vs.80).aspx


    Setting the parameter to false, stops the exception.

    Thanks.
     
    Waldy, Nov 15, 2007
    #7
    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. Anthony Williams
    Replies:
    9
    Views:
    3,656
  2. =?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,379
    Srowe1975
    Oct 15, 2008
  3. SteveWestling

    Security Exeception during upgrade

    SteveWestling, Nov 19, 2005, in forum: ASP .Net Security
    Replies:
    2
    Views:
    172
    SteveWestling
    Nov 20, 2005
  4. Sal
    Replies:
    1
    Views:
    1,048
  5. Replies:
    4
    Views:
    335
    Bob Barrows [MVP]
    Sep 22, 2006
Loading...

Share This Page