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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:27:00+00:00 2026-06-02T03:27:00+00:00

Is there a built in or a proper way to handle errors in asp.net

  • 0

Is there a built in or a proper way to handle errors in asp.net mvc 3?

This is what I want to do:

  1. If the application crashes, or throws an error, it goes to a specific error page.
  2. I can throw my own error from the controller action. (and it goes to an error page).

I found the following ways:

  1. I see there is a long way to do it
    here. (for v1 and v2 but also
    applies to v3).
  2. Using errorhandle attribute here.

How do I handle this the proper way?

If the solution is similar or is like #1 in the list above, I am using ninject and I have not created a base class. How do I still do 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-02T03:27:01+00:00Added an answer on June 2, 2026 at 3:27 am

    For Global Error Handling
    All you have to do is change the customErrors mode=”On” in web.config page
    Error will be displayed through Error.cshtml resides in shared folder.

    Make sure that Error.cshtml Layout is not null.

    [It sould be something like: @{ Layout = “~/Views/Shared/_Layout.cshtml”; }

    Or remove Layout=null code block]

    A sample markup for Error.cshtml:-

    @{ Layout = "~/Views/Shared/_Layout.cshtml"; } 
    
    @model System.Web.Mvc.HandleErrorInfo
    
    <!DOCTYPE html>
    <html>
    <head>
        <title>Error</title>
    </head>
    <body>
        <h2>
            Sorry, an error occurred while processing your request.
        </h2>
        <p>Controller Name: @Model.ControllerName</p>
        <p>Action Name : @Model.ActionName</p>
        <p>Message: @Model.Exception.Message</p>
    </body>
    </html>
    

    For Specific Error Handling
    Add HandleError attribute to specific action in controller class. Provide ‘View’ and ‘ExceptionType’ for that specific error.
    A sample NotImplemented Exception Handler:

    public class MyController: Controller
        {
            [HandleError(View = "NotImplErrorView", ExceptionType=typeof(NotImplementedException))]
            public ActionResult Index()
            {
                throw new NotImplementedException("This method is not implemented.");
                return View();
            }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is probably built-in function or a better and faster way to do this
Is there a built in way to get all of the media files (movies
Is there a built-in way to downsample an image in OpenCV 2.3.1 without prior
Is there a built in way to convert an integer in Ruby into its
Is there some built-in way to share files between Xen guests? I don't currently
Is there a built in function in .NET 2.0 that will take two arrays
I'd like to know whether there is a way to add an error handler
This answer shows that there is a built-in __name__ attribute of a function which
Recently started with ASP.NET and MVC and have a few questions on working with
Is there a built-in function/method that can check if a given string is 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.