Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9131711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T08:11:10+00:00 2026-06-17T08:11:10+00:00

I have a webforms project and I wanted to log all the 404 errors

  • 0

I have a webforms project and I wanted to log all the 404 errors in the Global.asax, so I put this code there:

void Application_Error(object sender, EventArgs e)
{
    var exception = Server.GetLastError();
    var httpException = exception as HttpException;
    if (httpException == null)
    {
        Log.Error(string.Format("Unkown error:", Request.Url.AbsoluteUri), exception);
    }
    else if (httpException.GetHttpCode() == 404)
    {
        Log.Warn(string.Format("RequestError 404: {0}", HttpContext.Current.Request.Url.AbsoluteUri));
    }
    else
    {
        Log.Error(string.Format("RequestError {0}: {2}\r\n{1}", httpException.GetHttpCode(), Server.UrlDecode(Request.Headers.ToString()), HttpContext.Current.Request.Url.AbsoluteUri), httpException);
    }
}

this works fine with all the request with the extension ‘.aspx’. Without it or with another extension the Application_Error is bypassed.

This is my web.config

<customErrors defaultRedirect="/500.aspx" mode="Off">
  <error statusCode="404" redirect="/404.aspx"/>
  <error statusCode="500" redirect="/500.aspx"/>
</customErrors>

Any idea?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T08:11:11+00:00Added an answer on June 17, 2026 at 8:11 am

    An error handler that is defined in the Global.asax file will only catch errors that occur during processing of requests by the ASP.NET runtime. For example, it will catch the error if a user requests an .aspx file that does not occur in your application. However, it does not catch the error if a user requests a nonexistent .htm file. For non-ASP.NET errors, you can create a custom handler in Internet Information Services (IIS). The custom handler will also not be called for server-level errors.

    This is extract from http://msdn.microsoft.com/en-us/library/24395wz3(v=vs.100).aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this authentication check in my global.asax file in the Session_OnStart() call: if
I have an asp.net webforms project. In there, an Admin has the ability to
ASP.NET 4.0 C# WebForms I have route.Ignore({resource}.axd/{*pathInfo}); in my global.asax for my ajax to
ASP.NET 4.0 Webforms project. I have the following in my code-behind. public partial class
I have just tried adding a WebService (asmx based) from a WebForms project to
I have a hybrid ASP.NET WebForms/MVC project. In my Master Page, I have a
I have an ASP.NET project (VS2008 on Windows 7 with either webforms, MVC1, or
I have an Umbraco 4.7.x project (.NET 4.0 webforms) where I want to compress
I have a webforms page that makes quite extensive use of AJAX. There are
I have an ASP.NET 3.5 webforms project written in VB that involves a multi-table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.