Question regarding detecting 404 Not Found

Discussion in 'ASP .Net' started by Jeff, Mar 2, 2010.

  1. Jeff

    Jeff Guest

    Hi

    asp.net 3.5

    I see in the statics for mys ite that about 50% of the request are 404 not
    found. so I'm setting up a NoSuchPage.aspx which I want the user to be
    redirected to when such error occur.

    <customErrors mode="RemoteOnly" defaultRedirect="AppErrors.aspx">
    <error statusCode="404" redirect="NoSuchPage.aspx"/>
    <error statusCode="403" redirect="NoAccessAllowed.aspx"/>
    </customErrors>

    In the NoSuchPage I want to write to the database which page the user
    requested.
    I'm unsure about how to get info about that Page. I've tryed
    Uri.AbsolutePath, but that only gave NoSuchPage.aspx... And
    Request.UrlReferrer gives compile error
    what you suggest?
     
    Jeff, Mar 2, 2010
    #1
    1. Advertisements

  2. Jeff

    Jeff Guest

    Okay, I've solved it. I use
    Request.RawUrl.ToString()



    "Jeff" <> wrote in message
    news:%...
    > Hi
    >
    > asp.net 3.5
    >
    > I see in the statics for mys ite that about 50% of the request are 404 not
    > found. so I'm setting up a NoSuchPage.aspx which I want the user to be
    > redirected to when such error occur.
    >
    > <customErrors mode="RemoteOnly" defaultRedirect="AppErrors.aspx">
    > <error statusCode="404" redirect="NoSuchPage.aspx"/>
    > <error statusCode="403" redirect="NoAccessAllowed.aspx"/>
    > </customErrors>
    >
    > In the NoSuchPage I want to write to the database which page the user
    > requested.
    > I'm unsure about how to get info about that Page. I've tryed
    > Uri.AbsolutePath, but that only gave NoSuchPage.aspx... And
    > Request.UrlReferrer gives compile error
    > what you suggest?
    >
    >
     
    Jeff, Mar 2, 2010
    #2
    1. Advertisements

  3. On Mar 2, 12:55 pm, "Jeff" <> wrote:
    > Hi
    >
    > asp.net 3.5
    >
    > I see in the statics for mys ite that about 50% of the request are 404 not
    > found. so I'm setting up a NoSuchPage.aspx which I want the user to be
    > redirected to when such error occur.
    >
    > <customErrors mode="RemoteOnly" defaultRedirect="AppErrors.aspx">
    >    <error statusCode="404" redirect="NoSuchPage.aspx"/>
    >    <error statusCode="403" redirect="NoAccessAllowed.aspx"/>
    > </customErrors>
    >
    > In the NoSuchPage I want to write to the database which page the user
    > requested.
    > I'm unsure about how to get info about that Page. I've tryed
    > Uri.AbsolutePath, but that only gave NoSuchPage.aspx... And
    > Request.UrlReferrer gives compile error
    > what you suggest?


    HttpRequest.UrlReferrer Property gets information about the URL of the
    client's previous request that linked to the current URL. You need to
    check if it is not null (UrlReferrer != null) because client can strip
    that header
     
    Alexey Smirnov, Mar 2, 2010
    #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. anon
    Replies:
    7
    Views:
    2,903
    David Wang [Msft]
    Apr 9, 2004
  2. Craig Wilson

    Trapping the 404 (resource not found) error

    Craig Wilson, Oct 7, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    554
    =?Utf-8?B?TGVvbiBXZWxpY2tp?=
    Oct 8, 2004
  3. Stan
    Replies:
    6
    Views:
    1,396
    Steven Cheng[MSFT]
    Oct 28, 2004
  4. =?Utf-8?B?QmVu?=

    error 404 page not found after appling patch

    =?Utf-8?B?QmVu?=, Oct 13, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    622
    =?Utf-8?B?QmVu?=
    Oct 19, 2005
  5. Brent Martin

    AXD 404 File or Directory Not Found Error

    Brent Martin, Nov 10, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    5,457
    epi_boy
    Jan 23, 2008
  6. Replies:
    0
    Views:
    23,057
  7. Replies:
    4
    Views:
    11,544
  8. Replies:
    0
    Views:
    583
Loading...