How to know if a redirect has been done?

Discussion in 'ASP .Net' started by Peter Row, Jan 20, 2004.

  1. Peter Row

    Peter Row Guest

    Hi,

    I am writing a DLL in VB.NET that implements IHttpHandler.ProcessRequest.
    This code calls a sub and I need to know if that sub did a response redirect
    or not.

    Specifically I need to know that either the sub did a redirect or a specific
    value
    was specified in the URL. If neither a redirect was done and a certain value
    was
    not specified in the URL then I need to throw an error. Check for the query
    string value is easy but how do I know if a redirect was done?

    Any help much appreciated.
    Regards,
    Peter Row
     
    Peter Row, Jan 20, 2004
    #1
    1. Advertising

  2. Cant you just add a param to the querystring indicating that it was part of
    a redirect request ie. redirected=true. Your checking the querystring
    anyway

    --
    Regards

    John Timney (Microsoft ASP.NET MVP)
    ----------------------------------------------
    <shameless_author_plug>
    Professional .NET for Java Developers with C#
    ISBN:1-861007-91-4
    Professional Windows Forms
    ISBN: 1861005547
    Professional JSP 2nd Edition
    ISBN: 1861004958
    Professional JSP
    ISBN: 1861003625
    Beginning JSP Web Development
    ISBN: 1861002092
    </shameless_author_plug>
    ----------------------------------------------

    "Peter Row" <> wrote in message
    news:...
    > Hi,
    >
    > I am writing a DLL in VB.NET that implements IHttpHandler.ProcessRequest.
    > This code calls a sub and I need to know if that sub did a response

    redirect
    > or not.
    >
    > Specifically I need to know that either the sub did a redirect or a

    specific
    > value
    > was specified in the URL. If neither a redirect was done and a certain

    value
    > was
    > not specified in the URL then I need to throw an error. Check for the

    query
    > string value is easy but how do I know if a redirect was done?
    >
    > Any help much appreciated.
    > Regards,
    > Peter Row
    >
    >
     
    John Timney \(Microsoft MVP\), Jan 20, 2004
    #2
    1. Advertising

  3. Peter Row

    Peter Row Guest

    Hi,

    No I can't because the redirect is made and then the code that runs after
    the .Redirect line
    needs to know if a redirect statement has been made.

    Therefore if the actual redirect has not actually taken place yet it's
    params won't be available.

    Anybody else have any thoughts?

    Regards,
    Peter Row
    "John Timney (Microsoft MVP)" <> wrote in message
    news:...
    > Cant you just add a param to the querystring indicating that it was part

    of
    > a redirect request ie. redirected=true. Your checking the querystring
    > anyway
    >
    > --
    > Regards
    >
    > John Timney (Microsoft ASP.NET MVP)
    > ----------------------------------------------
    > <shameless_author_plug>
    > Professional .NET for Java Developers with C#
    > ISBN:1-861007-91-4
    > Professional Windows Forms
    > ISBN: 1861005547
    > Professional JSP 2nd Edition
    > ISBN: 1861004958
    > Professional JSP
    > ISBN: 1861003625
    > Beginning JSP Web Development
    > ISBN: 1861002092
    > </shameless_author_plug>
    > ----------------------------------------------
    >
    > "Peter Row" <> wrote in message
    > news:...
    > > Hi,
    > >
    > > I am writing a DLL in VB.NET that implements

    IHttpHandler.ProcessRequest.
    > > This code calls a sub and I need to know if that sub did a response

    > redirect
    > > or not.
    > >
    > > Specifically I need to know that either the sub did a redirect or a

    > specific
    > > value
    > > was specified in the URL. If neither a redirect was done and a certain

    > value
    > > was
    > > not specified in the URL then I need to throw an error. Check for the

    > query
    > > string value is easy but how do I know if a redirect was done?
    > >
    > > Any help much appreciated.
    > > Regards,
    > > Peter Row
    > >
    > >

    >
    >
     
    Peter Row, Jan 20, 2004
    #3
  4. you could always put somthing in the session to say a redirect occured....

    --
    Regards

    John Timney (Microsoft ASP.NET MVP)
    ----------------------------------------------
    <shameless_author_plug>
    Professional .NET for Java Developers with C#
    ISBN:1-861007-91-4
    Professional Windows Forms
    ISBN: 1861005547
    Professional JSP 2nd Edition
    ISBN: 1861004958
    Professional JSP
    ISBN: 1861003625
    Beginning JSP Web Development
    ISBN: 1861002092
    </shameless_author_plug>
    ----------------------------------------------

    "Peter Row" <> wrote in message
    news:#...
    > Hi,
    >
    > No I can't because the redirect is made and then the code that runs after
    > the .Redirect line
    > needs to know if a redirect statement has been made.
    >
    > Therefore if the actual redirect has not actually taken place yet it's
    > params won't be available.
    >
    > Anybody else have any thoughts?
    >
    > Regards,
    > Peter Row
    > "John Timney (Microsoft MVP)" <> wrote in message
    > news:...
    > > Cant you just add a param to the querystring indicating that it was part

    > of
    > > a redirect request ie. redirected=true. Your checking the querystring
    > > anyway
    > >
    > > --
    > > Regards
    > >
    > > John Timney (Microsoft ASP.NET MVP)
    > > ----------------------------------------------
    > > <shameless_author_plug>
    > > Professional .NET for Java Developers with C#
    > > ISBN:1-861007-91-4
    > > Professional Windows Forms
    > > ISBN: 1861005547
    > > Professional JSP 2nd Edition
    > > ISBN: 1861004958
    > > Professional JSP
    > > ISBN: 1861003625
    > > Beginning JSP Web Development
    > > ISBN: 1861002092
    > > </shameless_author_plug>
    > > ----------------------------------------------
    > >
    > > "Peter Row" <> wrote in message
    > > news:...
    > > > Hi,
    > > >
    > > > I am writing a DLL in VB.NET that implements

    > IHttpHandler.ProcessRequest.
    > > > This code calls a sub and I need to know if that sub did a response

    > > redirect
    > > > or not.
    > > >
    > > > Specifically I need to know that either the sub did a redirect or a

    > > specific
    > > > value
    > > > was specified in the URL. If neither a redirect was done and a certain

    > > value
    > > > was
    > > > not specified in the URL then I need to throw an error. Check for the

    > > query
    > > > string value is easy but how do I know if a redirect was done?
    > > >
    > > > Any help much appreciated.
    > > > Regards,
    > > > Peter Row
    > > >
    > > >

    > >
    > >

    >
    >
     
    John Timney \(Microsoft MVP\), Jan 20, 2004
    #4
  5. Peter Row

    Peter Row Guest

    Hi,

    Hmmm.... not a bad thought, however in my app sessions are disabled.
    Isn't there some ASP object with some property or something available that
    tells you if a redirect is immanent?

    Regards,
    Peter Row
    "John Timney (Microsoft MVP)" <> wrote in message
    news:uT%...
    > you could always put somthing in the session to say a redirect occured....
    >
    > --
    > Regards
    >
    > John Timney (Microsoft ASP.NET MVP)
    > ----------------------------------------------
    > <shameless_author_plug>
    > Professional .NET for Java Developers with C#
    > ISBN:1-861007-91-4
    > Professional Windows Forms
    > ISBN: 1861005547
    > Professional JSP 2nd Edition
    > ISBN: 1861004958
    > Professional JSP
    > ISBN: 1861003625
    > Beginning JSP Web Development
    > ISBN: 1861002092
    > </shameless_author_plug>
    > ----------------------------------------------
    >
    > "Peter Row" <> wrote in message
    > news:#...
    > > Hi,
    > >
    > > No I can't because the redirect is made and then the code that runs

    after
    > > the .Redirect line
    > > needs to know if a redirect statement has been made.
    > >
    > > Therefore if the actual redirect has not actually taken place yet it's
    > > params won't be available.
    > >
    > > Anybody else have any thoughts?
    > >
    > > Regards,
    > > Peter Row
    > > "John Timney (Microsoft MVP)" <> wrote in message
    > > news:...
    > > > Cant you just add a param to the querystring indicating that it was

    part
    > > of
    > > > a redirect request ie. redirected=true. Your checking the querystring
    > > > anyway
    > > >
    > > > --
    > > > Regards
    > > >
    > > > John Timney (Microsoft ASP.NET MVP)
    > > > ----------------------------------------------
    > > > <shameless_author_plug>
    > > > Professional .NET for Java Developers with C#
    > > > ISBN:1-861007-91-4
    > > > Professional Windows Forms
    > > > ISBN: 1861005547
    > > > Professional JSP 2nd Edition
    > > > ISBN: 1861004958
    > > > Professional JSP
    > > > ISBN: 1861003625
    > > > Beginning JSP Web Development
    > > > ISBN: 1861002092
    > > > </shameless_author_plug>
    > > > ----------------------------------------------
    > > >
    > > > "Peter Row" <> wrote in message
    > > > news:...
    > > > > Hi,
    > > > >
    > > > > I am writing a DLL in VB.NET that implements

    > > IHttpHandler.ProcessRequest.
    > > > > This code calls a sub and I need to know if that sub did a response
    > > > redirect
    > > > > or not.
    > > > >
    > > > > Specifically I need to know that either the sub did a redirect or a
    > > > specific
    > > > > value
    > > > > was specified in the URL. If neither a redirect was done and a

    certain
    > > > value
    > > > > was
    > > > > not specified in the URL then I need to throw an error. Check for

    the
    > > > query
    > > > > string value is easy but how do I know if a redirect was done?
    > > > >
    > > > > Any help much appreciated.
    > > > > Regards,
    > > > > Peter Row
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Peter Row, Jan 21, 2004
    #5
  6. A redirect is really nothing but an instruction to the browser to change its
    address location and request a different page, hence the suggestion to add
    something to the URL the client is about to redirect too as a means of
    identifying that the redirect occured and re-entered the ISAPI pipeline. So
    you could detect it on the way back in and then throw your error.

    However, if your working in the ISAPI Pipeline via handlers anyway, you
    might want to take a look at the HttpWorkerRequest.EndOfSendNotification
    delegate, this occurs when a response is complete - in theory if you issue a
    response.redirect and a response.end then this should action as your
    response terminates and you may be able to add a means of detecting your
    redirection via this.

    http://authors.aspalliance.com/aspxtreme/sys/Web/httpworkerrequestendofsendn
    otificationclass.aspx

    Never tried it mind you.....

    --
    Regards

    John Timney (Microsoft ASP.NET MVP)
    ----------------------------------------------
    <shameless_author_plug>
    Professional .NET for Java Developers with C#
    ISBN:1-861007-91-4
    Professional Windows Forms
    ISBN: 1861005547
    Professional JSP 2nd Edition
    ISBN: 1861004958
    Professional JSP
    ISBN: 1861003625
    Beginning JSP Web Development
    ISBN: 1861002092
    </shameless_author_plug>
    ----------------------------------------------

    "Peter Row" <> wrote in message
    news:eLvgla$...
    > Hi,
    >
    > Hmmm.... not a bad thought, however in my app sessions are disabled.
    > Isn't there some ASP object with some property or something available that
    > tells you if a redirect is immanent?
    >
    > Regards,
    > Peter Row
    > "John Timney (Microsoft MVP)" <> wrote in message
    > news:uT%...
    > > you could always put somthing in the session to say a redirect

    occured....
    > >
    > > --
    > > Regards
    > >
    > > John Timney (Microsoft ASP.NET MVP)
    > > ----------------------------------------------
    > > <shameless_author_plug>
    > > Professional .NET for Java Developers with C#
    > > ISBN:1-861007-91-4
    > > Professional Windows Forms
    > > ISBN: 1861005547
    > > Professional JSP 2nd Edition
    > > ISBN: 1861004958
    > > Professional JSP
    > > ISBN: 1861003625
    > > Beginning JSP Web Development
    > > ISBN: 1861002092
    > > </shameless_author_plug>
    > > ----------------------------------------------
    > >
    > > "Peter Row" <> wrote in message
    > > news:#...
    > > > Hi,
    > > >
    > > > No I can't because the redirect is made and then the code that runs

    > after
    > > > the .Redirect line
    > > > needs to know if a redirect statement has been made.
    > > >
    > > > Therefore if the actual redirect has not actually taken place yet it's
    > > > params won't be available.
    > > >
    > > > Anybody else have any thoughts?
    > > >
    > > > Regards,
    > > > Peter Row
    > > > "John Timney (Microsoft MVP)" <> wrote in message
    > > > news:...
    > > > > Cant you just add a param to the querystring indicating that it was

    > part
    > > > of
    > > > > a redirect request ie. redirected=true. Your checking the

    querystring
    > > > > anyway
    > > > >
    > > > > --
    > > > > Regards
    > > > >
    > > > > John Timney (Microsoft ASP.NET MVP)
    > > > > ----------------------------------------------
    > > > > <shameless_author_plug>
    > > > > Professional .NET for Java Developers with C#
    > > > > ISBN:1-861007-91-4
    > > > > Professional Windows Forms
    > > > > ISBN: 1861005547
    > > > > Professional JSP 2nd Edition
    > > > > ISBN: 1861004958
    > > > > Professional JSP
    > > > > ISBN: 1861003625
    > > > > Beginning JSP Web Development
    > > > > ISBN: 1861002092
    > > > > </shameless_author_plug>
    > > > > ----------------------------------------------
    > > > >
    > > > > "Peter Row" <> wrote in message
    > > > > news:...
    > > > > > Hi,
    > > > > >
    > > > > > I am writing a DLL in VB.NET that implements
    > > > IHttpHandler.ProcessRequest.
    > > > > > This code calls a sub and I need to know if that sub did a

    response
    > > > > redirect
    > > > > > or not.
    > > > > >
    > > > > > Specifically I need to know that either the sub did a redirect or

    a
    > > > > specific
    > > > > > value
    > > > > > was specified in the URL. If neither a redirect was done and a

    > certain
    > > > > value
    > > > > > was
    > > > > > not specified in the URL then I need to throw an error. Check for

    > the
    > > > > query
    > > > > > string value is easy but how do I know if a redirect was done?
    > > > > >
    > > > > > Any help much appreciated.
    > > > > > Regards,
    > > > > > Peter Row
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    John Timney \(Microsoft MVP\), Jan 21, 2004
    #6
  7. Peter Row

    Peter Row Guest

    Hi,

    In my case it is the later. I issue a redirect but before that gets sent to
    the users browser for them to request; the rest of the response
    completes first. And it is here I need to know if a redirect has been issued
    which at the end of the response will be sent to the users
    browser and hence cause another request.

    However I have been having a bit of a brain guff!
    I have an Asp wrapper class which has a RedirectSafely() method to get
    around the phaff needed to stop ThreadAbortedExceptions
    from occuring. Therefore since I always call this instead of
    Response.Redirect directly all I need to do is set a private member
    variable flag to indicate it has been called. My implementation of
    IHttpHandler.ProcessRequest can then check this and raise the
    appropriate error when RedirectNotDone AndAlso QueryString("XXX") = ""

    Thanks for taking time to think it over any way.
    Regards,
    Peter Row

    "John Timney (Microsoft MVP)" <> wrote in message
    news:...
    > A redirect is really nothing but an instruction to the browser to change

    its
    > address location and request a different page, hence the suggestion to add
    > something to the URL the client is about to redirect too as a means of
    > identifying that the redirect occured and re-entered the ISAPI pipeline.

    So
    > you could detect it on the way back in and then throw your error.
    >
    > However, if your working in the ISAPI Pipeline via handlers anyway, you
    > might want to take a look at the HttpWorkerRequest.EndOfSendNotification
    > delegate, this occurs when a response is complete - in theory if you issue

    a
    > response.redirect and a response.end then this should action as your
    > response terminates and you may be able to add a means of detecting your
    > redirection via this.
    >
    >

    http://authors.aspalliance.com/aspxtreme/sys/Web/httpworkerrequestendofsendn
    > otificationclass.aspx
    >
    > Never tried it mind you.....
    >
    > --
    > Regards
    >
    > John Timney (Microsoft ASP.NET MVP)
    > ----------------------------------------------
    > <shameless_author_plug>
    > Professional .NET for Java Developers with C#
    > ISBN:1-861007-91-4
    > Professional Windows Forms
    > ISBN: 1861005547
    > Professional JSP 2nd Edition
    > ISBN: 1861004958
    > Professional JSP
    > ISBN: 1861003625
    > Beginning JSP Web Development
    > ISBN: 1861002092
    > </shameless_author_plug>
    > ----------------------------------------------
    >
    > "Peter Row" <> wrote in message
    > news:eLvgla$...
    > > Hi,
    > >
    > > Hmmm.... not a bad thought, however in my app sessions are disabled.
    > > Isn't there some ASP object with some property or something available

    that
    > > tells you if a redirect is immanent?
    > >
    > > Regards,
    > > Peter Row
    > > "John Timney (Microsoft MVP)" <> wrote in message
    > > news:uT%...
    > > > you could always put somthing in the session to say a redirect

    > occured....
    > > >
    > > > --
    > > > Regards
    > > >
    > > > John Timney (Microsoft ASP.NET MVP)
    > > > ----------------------------------------------
    > > > <shameless_author_plug>
    > > > Professional .NET for Java Developers with C#
    > > > ISBN:1-861007-91-4
    > > > Professional Windows Forms
    > > > ISBN: 1861005547
    > > > Professional JSP 2nd Edition
    > > > ISBN: 1861004958
    > > > Professional JSP
    > > > ISBN: 1861003625
    > > > Beginning JSP Web Development
    > > > ISBN: 1861002092
    > > > </shameless_author_plug>
    > > > ----------------------------------------------
    > > >
    > > > "Peter Row" <> wrote in message
    > > > news:#...
    > > > > Hi,
    > > > >
    > > > > No I can't because the redirect is made and then the code that runs

    > > after
    > > > > the .Redirect line
    > > > > needs to know if a redirect statement has been made.
    > > > >
    > > > > Therefore if the actual redirect has not actually taken place yet

    it's
    > > > > params won't be available.
    > > > >
    > > > > Anybody else have any thoughts?
    > > > >
    > > > > Regards,
    > > > > Peter Row
    > > > > "John Timney (Microsoft MVP)" <> wrote in

    message
    > > > > news:...
    > > > > > Cant you just add a param to the querystring indicating that it

    was
    > > part
    > > > > of
    > > > > > a redirect request ie. redirected=true. Your checking the

    > querystring
    > > > > > anyway
    > > > > >
    > > > > > --
    > > > > > Regards
    > > > > >
    > > > > > John Timney (Microsoft ASP.NET MVP)
    > > > > > ----------------------------------------------
    > > > > > <shameless_author_plug>
    > > > > > Professional .NET for Java Developers with C#
    > > > > > ISBN:1-861007-91-4
    > > > > > Professional Windows Forms
    > > > > > ISBN: 1861005547
    > > > > > Professional JSP 2nd Edition
    > > > > > ISBN: 1861004958
    > > > > > Professional JSP
    > > > > > ISBN: 1861003625
    > > > > > Beginning JSP Web Development
    > > > > > ISBN: 1861002092
    > > > > > </shameless_author_plug>
    > > > > > ----------------------------------------------
    > > > > >
    > > > > > "Peter Row" <> wrote in message
    > > > > > news:...
    > > > > > > Hi,
    > > > > > >
    > > > > > > I am writing a DLL in VB.NET that implements
    > > > > IHttpHandler.ProcessRequest.
    > > > > > > This code calls a sub and I need to know if that sub did a

    > response
    > > > > > redirect
    > > > > > > or not.
    > > > > > >
    > > > > > > Specifically I need to know that either the sub did a redirect

    or
    > a
    > > > > > specific
    > > > > > > value
    > > > > > > was specified in the URL. If neither a redirect was done and a

    > > certain
    > > > > > value
    > > > > > > was
    > > > > > > not specified in the URL then I need to throw an error. Check

    for
    > > the
    > > > > > query
    > > > > > > string value is easy but how do I know if a redirect was done?
    > > > > > >
    > > > > > > Any help much appreciated.
    > > > > > > Regards,
    > > > > > > Peter Row
    > > > > > >
    > > > > > >
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Peter Row, Jan 21, 2004
    #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. muskan
    Replies:
    1
    Views:
    333
    Ioannis Vranos
    Sep 22, 2004
  2. Python Baby
    Replies:
    2
    Views:
    254
    Graham Fawcett
    Jan 28, 2004
  3. DaveB
    Replies:
    3
    Views:
    320
    DaveB
    Apr 11, 2010
  4. Replies:
    2
    Views:
    120
  5. Dr J R Stockton

    Suggestion for FAQ, *OR* has it been done (URL?)

    Dr J R Stockton, May 15, 2010, in forum: Javascript
    Replies:
    0
    Views:
    80
    Dr J R Stockton
    May 15, 2010
Loading...

Share This Page