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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T20:10:47+00:00 2026-06-03T20:10:47+00:00

I am using a global ErrorHandler filter to log unhandled exceptions, but I would

  • 0

I am using a global ErrorHandler filter to log unhandled exceptions, but I would also like to be able to use this same handler to log handled exceptions from within a catch block.

I would like to access the global filters and execute the ErrorHandler as configured, but I’m having some difficulty doing this. I tried the following, but Resharper is telling me that the filter can’t ever be my ErrorLogFilter.

foreach (var filter in GlobalFilters.Filters)
{
    if (filter is ErrorLogFilter) // Static analysis tells me this can never be an ErrorLogFilter
    {
        // want to execute the filter
    }
}

ErrorLogFilter is added to the global filters like this:

GlobalFilters.Filters.Add(new ErrorLogFilter(provider));

ErrorLogFilter (as part of Elfar, similar to Elmah, but for MVC) is defined as:

public class ErrorLogFilter : FilterAttribute, IExceptionFilter

Any suggestions on how to accomplish 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-03T20:10:48+00:00Added an answer on June 3, 2026 at 8:10 pm

    GlobalFilters.Filters is a GlobalFilterCollection which contains Filter‘s which are wrappers around the added IMvcFilters.

    Try this instead:

    foreach (var filter in GlobalFilters.Filters)
    {
        if (filter.Instance is ErrorLogFilter)
        {
            // want to execute the filter
        }
    }
    

    So Reshaper is correct signaled that there is no ErrorLogFilter in GlobalFilters.Filters.

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

Sidebar

Related Questions

I would like to use a configuration in the .config file like this: <appSettings>
I always hear using global variables are dangerous. Does this apply to Drupal? Take
I've tried using a global hook but the hookprocedure only recieved window procedure messages
I'm using a global keyboard hook class. This class allows to check if keyboard
I'm writing a custom ErrorHandler attribute for my MVC project. I would like to
I'm using Struts 1.3.10 to run a site. Everything works well, but I'd like
I'm using global variables to pass around a response from a AJAX call: window.response
I am trying to implement protein pairwise sequence alignment using Global Alignment algorithm by
How i can declare a global method in delphi prism using the __Global class?
Is there a way to handle the application_start event without using the global.asax? 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.