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 9061123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:24:23+00:00 2026-06-16T15:24:23+00:00

My intention is to log an error(I am using Log4Net) when an exception is

  • 0

My intention is to log an error(I am using Log4Net) when an exception is caught and redirect to a pretty looking page with some error message. I have a class that returns a Type T object , mostly a DataSet.

In my Catch statement I wrote this, it works but I am not sure if there’s a more appropriate way of handling, can someone please advice. Thanks. Note that the throw cannot be omitted because the class has a return type.:

      catch (Exception ex)
        {
            log.Error(ex);
            HttpContext.Current.Response.Redirect("~/errorPage.aspx");
            throw ex;
        }
  • 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-16T15:24:24+00:00Added an answer on June 16, 2026 at 3:24 pm

    It depends upon how you want to handle error on the page, In general , unhandled exception should be bubbled up to application_error in gloabl.asax file to it generic.Here is one simple way to handle this error.

    void Application_Error(object sender, EventArgs e)
    {
    // Code that runs when an unhandled error occurs
    // Get the exception object.
    Exception exc = Server.GetLastError();
    
    // Handle HTTP errors
    if (exc.GetType() == typeof(HttpException))
    {
    // The Complete Error Handling Example generates
    // some errors using URLs with "NoCatch" in them;
    // ignore these here to simulate what would happen
    // if a global.asax handler were not implemented.
      if (exc.Message.Contains("NoCatch") || exc.Message.Contains("maxUrlLength"))
      return;
    
    //Redirect HTTP errors to HttpError page
      Server.Transfer("HttpErrorPage.aspx");
    }
    
      // For other kinds of errors give the user some information
     // but stay on the default page
      Response.Write("<h2>Global Page Error</h2>\n");
     Response.Write(
      "<p>" + exc.Message + "</p>\n");
      Response.Write("Return to the <a href='Default.aspx'>" +
      "Default Page</a>\n");
    
     // Log the exception and notify system operators
     ExceptionUtility.LogException(exc, "DefaultPage");
     ExceptionUtility.NotifySystemOps(exc);
    
     // Clear the error from the server
     Server.ClearError();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

By looking at our DB's error log, we found that there was a constant
I have some custom error classes defined, each with their own functionality (not shown):
In logging frameworks like log4j & log4net you have the ability to log various
My intention is to have 4 main Nav-bars at a site. If the user
My intention is to have a user initiate a status update from a webpage
I'm trying to use mysql_real_escape_string() to secure a log in form. Using this code:
I have a script done by myself that uses jQuery Ajax functions to log
I have the following MainActivity.java file currently running on Eclipse. My intention is to
I have made my first attempt at using dependency injection to loosely couple a
I'm using byobu /screen, and I would like to have a new screen session

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.