aspx to return a 404 with a friendly page inc/Session?

Discussion in 'ASP .Net' started by Dunc, Jul 17, 2008.

  1. Dunc

    Dunc Guest

    Has anyone got a way to get asp.net to return a result code of 404
    with a friendly page of any substance?

    I have been trying to do a Server.Transfer from the global.asax.cs
    Application_Error function, but because there's no access to the
    session at this point (Application_OnAuthenticateRequest hasn't fired)
    and my master page checks session values based on the transferred
    context (that has no session when transferred from the error handler),
    I get an error.

    If I use Response.Redirect or the <customerrors> tag, I get a response
    code of 302.

    I've set up IIS to point to the aspx file, but that only works if the
    user hits a non-existant page without an aspx extension; any aspx file
    gets handled by .net and we end up with either a response code of 302
    or an error.

    This is REALLY annoying, as every time a page name changes, I end up
    with legacy search engine traffic I don't want. I've been trying to
    do this for a long time now; there must be some solution out there?

    Thanks in advance,

    Duncan
     
    Dunc, Jul 17, 2008
    #1
    1. Advertisements

  2. Hello Dunc,

    Have u tried to implement the httphandler for this, where your session will
    be available via IReadOnlySessionState|IRequiresSessionState.

    see discussion there http://forums.asp.net/p/1273530/2414745.aspx

    ---
    WBR,
    Michael Nemtsev [Microsoft MVP] :: blog: http://spaces.live.com/laflour

    "The greatest danger for most of us is not that our aim is too high and we
    miss it, but that it is too low and we reach it" (c) Michelangelo


    D> Has anyone got a way to get asp.net to return a result code of 404
    D> with a friendly page of any substance?
    D>
    D> I have been trying to do a Server.Transfer from the global.asax.cs
    D> Application_Error function, but because there's no access to the
    D> session at this point (Application_OnAuthenticateRequest hasn't
    D> fired) and my master page checks session values based on the
    D> transferred context (that has no session when transferred from the
    D> error handler), I get an error.
    D>
    D> If I use Response.Redirect or the <customerrors> tag, I get a
    D> response code of 302.
    D>
    D> I've set up IIS to point to the aspx file, but that only works if the
    D> user hits a non-existant page without an aspx extension; any aspx
    D> file gets handled by .net and we end up with either a response code
    D> of 302 or an error.
    D>
    D> This is REALLY annoying, as every time a page name changes, I end up
    D> with legacy search engine traffic I don't want. I've been trying to
    D> do this for a long time now; there must be some solution out there?
    D>
    D> Thanks in advance,
    D>
    D> Duncan
    D>
     
    Michael Nemtsev [MVP], Jul 17, 2008
    #2
    1. Advertisements

  3. Dunc

    Dunc Guest

    Thanks for the response; unfortunately the method they're chasing is
    has almost identical problems to the one I've found. Because you're
    adding a handler for context.Error, there's no
    Application_OnAuthenticateRequest, which means no session, which means
    it bombs when it does a Server.Transfer to a page that has a master
    page with some very basic functionality.

    Any other ideas?


    On Jul 17, 12:29 pm, Michael Nemtsev [MVP] <> wrote:
    > Hello Dunc,
    >
    > Have u tried to implement the httphandler for this, where your session will
    > be available via IReadOnlySessionState|IRequiresSessionState.
    >
    > see discussion therehttp://forums.asp.net/p/1273530/2414745.aspx
    >
    > ---
    > WBR,
    > Michael  Nemtsev [Microsoft MVP] :: blog:http://spaces.live.com/laflour
    >
    > "The greatest danger for most of us is not that our aim is too high and we
    > miss it, but that it is too low and we reach it" (c) Michelangelo
    >
    > D> Has anyone got a way to get asp.net to return a result code of 404
    > D> with a friendly page of any substance?
    > D>
    > D> I have been trying to do a Server.Transfer from the global.asax.cs
    > D> Application_Error function, but because there's no access to the
    > D> session at this point (Application_OnAuthenticateRequest hasn't
    > D> fired) and my master page checks session values based on the
    > D> transferred context (that has no session when transferred from the
    > D> error handler), I get an error.
    > D>
    > D> If I use Response.Redirect or the <customerrors> tag, I get a
    > D> response code of 302.
    > D>
    > D> I've set up IIS to point to the aspx file, but that only works if the
    > D> user hits a non-existant page without an aspx extension; any aspx
    > D> file gets handled by .net and we end up with either a response code
    > D> of 302 or an error.
    > D>
    > D> This is REALLY annoying, as every time a page name changes, I end up
    > D> with legacy search engine traffic I don't want.  I've been trying to
    > D> do this for a long time now; there must be some solution out there?
    > D>
    > D> Thanks in advance,
    > D>
    > D> Duncan
    > D>
     
    Dunc, Jul 18, 2008
    #3
    1. Advertisements

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. Jonathan Folland
    Replies:
    2
    Views:
    1,813
    Jonathan Folland
    Mar 17, 2005
  2. frekster
    Replies:
    1
    Views:
    1,055
    frekster
    Sep 14, 2005
  3. Leif K-Brooks
    Replies:
    4
    Views:
    949
    Firas D.
    Feb 12, 2004
  4. Replies:
    1
    Views:
    689
    David
    Apr 24, 2007
  5. Replies:
    3
    Views:
    1,989
Loading...

Share This Page