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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:56:11+00:00 2026-06-13T23:56:11+00:00

In each action, I write: public ActionResult Foo() { try { // Do something

  • 0

In each action, I write:

public ActionResult Foo()
{
    try
    {
        // Do something
    }
    catch(Exception ex)
    {
        Logger.Error("Foo()", ex);
    }
    ...
}

I know MVC3 has the ability to “RegisterGlobalFilters” in Global.asax, so I want to write a custom LogExceptionAttribute. which will:

  1. Log information of which Action cause what Exception. calling my Logger API:

    Logger.Error(string actionName, Exception ex)

  2. throw the exception again. so that CustomError in web.config will show user error page.

How to implement this?

  • 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-13T23:56:12+00:00Added an answer on June 13, 2026 at 11:56 pm

    Try this

      public class HandleErrorHmAttribute : HandleErrorAttribute
            {
                public override void OnException(ExceptionContext context)
                {
                    base.OnException(context);
                    new WebRequestErrorEventMvc("An unhandled exception has occurred.", this, 103005, context.Exception).Raise();
                }
            }
    
            public class WebRequestErrorEventMvc : WebRequestErrorEvent
            {
                public WebRequestErrorEventMvc(string message, object eventSource, int eventCode, Exception exception) : base(message, eventSource, eventCode, exception) { }
                public WebRequestErrorEventMvc(string message, object eventSource, int eventCode, int eventDetailCode, Exception exception) : base(message, eventSource, eventCode, eventDetailCode, exception) { }
           }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can we run a method before running each Action in MVC3? I know
I have an action [HttpPost] public string Edit(Member member) and Member has a collection
I want each action taken on certain tables to be logged. I want logging
I'm logging different actions users make on our website. Each action can be of
My project had audit module, which includes each and every action of the user
How to create jinternalframes who's action depends on each other? example suppose i have
what is the best way to implement some action that should be executed each
I have to implement a few action. Each of they have some common elements,
I have a submenu that list departments. Behind this each department have an action
The following line in my news_lists_controller.rb file is generating an error: (1 .. @tot_actions).each

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.