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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:09:19+00:00 2026-05-26T20:09:19+00:00

In ASP.NET MVC im overwriting the OnException, so I can do some custom error

  • 0

In ASP.NET MVC im overwriting the OnException, so I can do some custom error handling on exceptions. One thing I would like to do here is to log from what area in the webapplication the error happend.

For example we have Webshop and Administration areas in the webapplications. Then I would like to identify if the exception comes from a Webshop controller or an Administration controller. This is what I have:

protected override void OnException(ExceptionContext filterContext)
        {
            if (filterContext.Exception != null)
            {
                ErrorTargetType targetErrorType = ErrorTargetType.DipService;

                if (filterContext.Controller is CatalogController)
                    targetErrorType = ErrorTargetType.WebshopInterface;

                LogException(filterContext.Exception, targetErrorType);
            }
            base.OnException(filterContext);
        }

It works fine but I would like do the if statement on a collection of Administration controllers insted. Does ASP.NET MVC have some standard functionality which provides all the controllers in the webapplication in a collection, if so, how do I separate the Webshop controllers from the Administration controllers?

  • 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-05-26T20:09:20+00:00Added an answer on May 26, 2026 at 8:09 pm

    all the controllers in the webapplication in a collection

    A collection of controllers or controllers group is a notion that doesn’t exist in ASP.NET MVC nor it makes much sense. The fact that you call ControllerA, ControllerB and ControllerC being part of Administration is a notion that only you have defined. The sole notion of Administration hardly makes any sense in ASP.NET MVC. In ASP.NET MVC you have Models, Views and of course Controllers.

    if so, how do i seperate the Webshop controllers from the Administration controllers?

    Make them derive from a common base controller or make them implement a marker interface.

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

Sidebar

Related Questions

With ASP.NET MVC (or using HttpHandlers) you can dynamically generate URLs, like the one
In my ASP.NET MVC app, I'm handling errors by overriding OnException in the controller.
ASP.NET MVC can generate HTML elements using HTML Helpers, for example @Html.ActionLink() , @Html.BeginForm()
ASP.NET MVC 2 will support validation based on DataAnnotation attributes like this: public class
ASP .NET MVC 1 I'd like to show a partial view base on a
I've some experiences on build application with Asp.Net, but now MVC frameworks become more
ASP.Net MVC 3 using C# I currently have a form with some dropdown lists
Asp.Net MVC 3 FormsAuthentication (custom) iPad MobileSafari iframe (same domain) After struggling with formsTicket.UserData
ASP.Net MVC applications has two web.config s. One in the root folder and one
ASP.Net MVC 3 RC, Razor Experiencing some unexpected behavior when I try to use

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.