Non-existent page is not throwing 404 error

Discussion in 'ASP .Net' started by Joel D. Kraft, May 24, 2005.

  1. I've been logging a lot of fatal errors on my site lately, and I
    have not been able to figure out why.

    First, my site has error handling pages defined globally as shown
    below. They are not overridden at any point in the configuration.

    <customErrors mode="RemoteOnly"
    defaultRedirect="/site/error/default.aspx">
    <error statusCode="404" redirect="/site/error/404.aspx" />
    </customErrors>

    Oddly enough, I am getting exceptions logged that SHOULD be sent to
    the 404 page. In this instance, the page requested is
    /site/news/rss_sharepoint.aspx. THIS PAGE DOES NOT AND SHOULD
    NOT EXIST, which is obviously why it cannot find what it is looking
    for. The question is WHY is it getting this far, instead of going
    to my 404 handler?

    Request: /site/news/rss_sharepoint.aspx
    UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5)
    Gecko/20041206 Thunderbird/1.0
    Username: (none)
    -----
    System.IO.FileNotFoundException:
    C:\InetSrv\wwwroot\site\news\rss_sharepoint.aspx
    at System.Web.UI.TemplateParser.GetParserCacheItem()
    at
    System.Web.UI.TemplateControlParser.CompileAndGetParserCacheItem(String
    virtualPath, String inputFile, HttpContext context)
    at System.Web.UI.TemplateControlParser.GetCompiledInstance(String
    virtualPath, String inputFile, HttpContext context)
    at System.Web.UI.PageParser.GetCompiledPageInstanceInternal(String
    virtualPath, String inputFile, HttpContext context)
    at System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context,
    String requestType, String url, String path)
    at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String
    requestType, String path, String pathTranslated, Boolean useAppConfig)

    To make things more confusing, I cannot reproduce it. If I
    try to visit the page, I get the 404 page every time. But I'm getting
    these errors logged a lot. Any insights?

    Thanks!
    Joel

    --
    ------------------------------------------------------------------------
    Email : | Case Western Reserve University
    Phone : 216-368-3780 | Department of Housing & Residence Life
    FAX : 216-368-6658 | http://housing.case.edu/
    ------------------------------------------------------------------------
     
    Joel D. Kraft, May 24, 2005
    #1
    1. Advertising

  2. Joel D. Kraft

    Guest

    Hi Joel,
    It might be because the Application_Error event fires before the
    redirection to 404 handler happens.

    Regards,
    Arun Prakash. B
     
    , May 24, 2005
    #2
    1. Advertising

  3. Joel D. Kraft

    Brock Allen Guest

    Arun is right -- 404 is handled by ASP.NET throwing an exception, and your
    Application_Error sounds like it's loggin everything that passes thru it.
    If you only want the errors in your pages and not these ASP.NET exceptions,
    you should check in Application_Error for HttpUnhandledException:

    void Application_Error(...)
    {
    if (Context.Error is HttpUnhandledException)
    {
    // this is an error from one of my pages
    }
    }

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Hi Joel,
    > It might be because the Application_Error event fires before the
    > redirection to 404 handler happens.
    > Regards,
    > Arun Prakash. B
     
    Brock Allen, May 24, 2005
    #3
  4. > Arun is right -- 404 is handled by ASP.NET throwing an exception, and
    > your Application_Error sounds like it's loggin everything that passes
    > thru it. > If you only want the errors in your pages and not these
    > ASP.NET exceptions, you should check in Application_Error for
    > HttpUnhandledException:
    >
    > void Application_Error(...)
    > {
    > if (Context.Error is HttpUnhandledException)
    > {
    > }
    > }


    DOH. This got me to finally dig up a comprehensive reference
    on how the errors filter through the page, application and config.
    I ended up rewriting my entire error handling mechanism. The
    CustomErrors wasn't cutting it for me anyway.

    Thanks guys!
    Joel
     
    Joel D. Kraft, May 25, 2005
    #4
    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. Paul W

    Non-existent datagrid?

    Paul W, Nov 10, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    338
    Paul W
    Nov 10, 2004
  2. ElGordo
    Replies:
    2
    Views:
    6,155
    Ersin Gençtürk
    Apr 29, 2005
  3. dkode
    Replies:
    4
    Views:
    782
    dkode
    Apr 12, 2006
  4. Greg Sandell
    Replies:
    2
    Views:
    506
    Dimitre Novatchev
    Oct 8, 2003
  5. Les Caudle
    Replies:
    1
    Views:
    349
    Cowboy \(Gregory A. Beamer\)
    Sep 19, 2006
Loading...

Share This Page