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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:34:43+00:00 2026-06-13T22:34:43+00:00

Using an API controller in MVC4, when the controller action throws an exception, ELMAH

  • 0

Using an API controller in MVC4, when the controller action throws an exception, ELMAH does not log the error.

I think the problem is that MVC4 sets the HTTP status code to 500, and it returns the exception details in a JSON object, but it does not throw an unhandled exception so ELMAH never sees it.

How can I get ELMAH to capture all responses where the status code is not 200?

  • 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-13T22:34:44+00:00Added an answer on June 13, 2026 at 10:34 pm

    The anwser described before doesn’t work. I’ve tried on my test server and received an error (“The given filter instance must implement one or more of the following filter interfaces: IAuthorizationFilter, IActionFilter, IResultFilter, IExceptionFilter.”)

    Then I realized what happened …. you are trying to add the custom filter to the MVC Global Filter (filters.Add(new ElmahHandledErrorLoggerFilter());)

    To fix that, I’ve split the filter registration in GlobalFilter and HttpFilter

    FilterConfig.cs

        public static void RegisterGlobalFilters(GlobalFilterCollection filters)
        {
            filters.Add(new HandleErrorAttribute());
        }
    
        public static void RegisterHttpFilters(HttpFilterCollection filters)
        {
            filters.Add(new ElmahHandledErrorLoggerFilter());
        }
    

    Global.asax

        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        FilterConfig.RegisterHttpFilters(GlobalConfiguration.Configuration.Filters);
    

    😉

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

Sidebar

Related Questions

I am using MVC4's WEB API to expose a controller. Initially I created created
My problem is in using Codeigniter custom library but I think it is not
Problem: I'm using MVC4 WebAPI and am throwing an error during a Get() call.
Using the ASP.NET Web-Api, I have the following POST setup in my controller. When
I am starting to use MVC4 Web API project, I have controller with multiple
Here is the code that I am using to set the api url: var
I'm using an API that makes heavy use of Iterables (java.lang.Iterable), but I can't
I am trying to build an API using Rails that will inspect the request
I'm using MVC 4 web api that comes with visual studio 2012. As I've
I'm having big trouble testing with rSpec's controller API. Right now I'm using a

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.