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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:43:59+00:00 2026-05-23T04:43:59+00:00

I want to handle application wide error and show a ErrorView page in asp.net

  • 0

I want to handle application wide error and show a ErrorView page in asp.net mvc.
There are 3 ways to do it (or i know).

1) ErrorAttribute in BaseController:Controller class.
     Can be used on individual Action/Controller/BaseController.
2) Override OnException() in the BaseController:Controller class.
     Will work on Controllers derived from BaseController
3) Application_Error in Global_aspx.

What is the best practice.
Which one of these methods should be used for application wide error handling or should we use multiple or only one.

If we handle error on ErrorAttribute Or/And OnException() on BaseController should we still handle it in Application_Error().

When should we use Application_Error()?

  • 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-23T04:44:00+00:00Added an answer on May 23, 2026 at 4:44 am
    1. HandleErrorAttribute is an MVC filter applied via the attribute. You can supply a view name to display if an exception occurs and you can also specify the base (or specific) type of exception this filter applies to. If no view name is supplied it will look for a view named “Error”. As you’ve already noticed you can apply it to various scopes. It allows you to specify a different “error page” view based on the exception.

    2. Controller.OnException is a method that will get called if any of your actions ends up throwing an error.

    3. Both of the above two are MVC concepts and part of the MVC pipeline, which sits on top of the ASP.NET pipeline, and if you handle the exception using the above it won’t propagate to Application_Error, but things like http errors 404, 500 and will if I remember correctly.

    What to use?

    Definitely look into ELMAH for application wide error logging and my blog post about ELMAH and ASP.NET MVC

    Regarding displaying error pages you should be fine with just using [HandleError] and the HandleErrorAttribute, since it already handles everything for you (optional filtering and optional custom error page per exception type).

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

Sidebar

Related Questions

I want to handle uncaught exceptions in my ASP.NET MVC 3 application, so that
How to handle Application_BeginRequest using a custom filter in asp.net mvc? I want to
I'm trying to build an ASP.NET MVC 2 application. I want to pass data
In my ASP.NET MVC 2 web application, I allow users to create custom input
How to know if the request is ajax in asp.net in Application_Error() I want
I want to handle the keydown event globally in my application and as such
I have several thread pools and I want my application to handle a cancel
I'm using attachment_fu in a rails application to handle file uploads, and i want
I have a webview in my application. I want to handle when user copies
I'm writing a Google App Engine Go application. In it, I want to handle

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.