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

  • Home
  • SEARCH
  • 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 8756177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:00:50+00:00 2026-06-13T14:00:50+00:00

I am attempting to catch all errors except ‘404-File not found’ error in global.asax

  • 0

I am attempting to catch all errors except ‘404-File not found’ error in global.asax file and writing in to a text file in server,But lot of errors gets missed ,like FormatException Error,Sessionout Error and “Yellow Page of Error” Appears !

How can I catch all errors here.

void Application_Error(object sender, EventArgs e) 
{
    CT.Bussiness.DevCommonFunctions devTools = new CT.Bussiness.DevCommonFunctions();
    HttpContext ctx = HttpContext.Current;
    //ctx.Response.
    // Get page url
    if (ctx != null)
    {
        string pageName = ctx.Request.Url.ToString();

        Exception ex = Server.GetLastError().GetBaseException();
        HttpException checkException = (HttpException)ex;
        if (checkException.GetHttpCode() != 404)
        {
            string errorDate = DateTime.Now.ToString();
            //string pageName =pageName;
            string errorMessage = ex.Message;
            string errorSource = ex.Source;
            //string errorInnerException=ex.InnerException.ToString();
            string errorData = ex.Data.ToString();
            string errorTarget = ex.TargetSite.ToString();
            string errorStack = ex.StackTrace.ToString();
            devTools.WriteErrorsIntoErrorLog(errorDate, pageName, errorMessage, errorSource, "InnerException", errorData, errorTarget, errorStack);
            //devTools.SendErrorMail("developer3@devwebservices.net,developer4@devwebservices.net,developer5@devwebservices.net,hr@devwebservices.net", errorDate, pageName, errorMessage, errorSource, "InnerException", errorData, errorTarget, errorStack);
            //Response.TrySkipIisCustomErrors = true;
            Response.Redirect("~/Error.aspx");
            //Response.Redirect("Error.aspx");

        }
    }
}

SOLVED

I Followed Like this as KPL Adviced below:

  1. Implemented Elmah
  2. Excluded Global.asax and
  3. Wrote redirection code in web.config.

Thus Solved !

  • 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-13T14:00:51+00:00Added an answer on June 13, 2026 at 2:00 pm

    Use:

    1.) web.config “customErrors” tag to avoid “Yellow Page of Error”:

    <customErrors mode="On" defaultRedirect="~/Error.aspx">
          <error statusCode="400" redirect="/error/400-bad-request/" />
          <error statusCode="404" redirect="/error/404-file-not-found/" />
          <error statusCode="500" redirect="/error/500-server-error/" />
    </customErrors>
    

    2.) Also try using Elmah to logging errors.

    ELMAH (Error Logging Modules and Handlers) is an application-wide error logging facility that is completely pluggable. It can be dynamically added to a running ASP.NET web application, or even all ASP.NET web applications on a machine, without any need for re-compilation or re-deployment.

    Once ELMAH has been dropped into a running web application and configured appropriately, you get the following facilities without changing a single line of your code:

    • Logging of nearly all unhandled exceptions.
    • A web page to remotely view the entire log of recoded exceptions.
    • A web page to remotely view the full details of any one logged exception, including colored stack traces.
    • In many cases, you can review the original yellow screen of death that ASP.NET generated for a given exception, even with customErrors mode turned off.
    • An e-mail notification of each error at the time it occurs.
    • An RSS feed of the last 15 errors from the log.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am attempting to catch the last case in a forEach loop, but all
Attempting to build a C# NPAPI plugin I have found a tutorial which describes
Can a template template variadic be used to catch all cases of a template
All, While this is similar to another post , that post (does not indicate
I'm writing a short test app to practice connecting to a server. All the
I have a small problem. I'm attempting to catch the OnUnLoad Event of the
I am attempting to route a URL that does not have a static action
I'm attempting to recursively copy all files and directories and here is my class
As detailed here: Need assistance with Kohana 3 and catch all route turning into
I'm attempting to list off all exif attributes associated with an image in the

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.