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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:35:04+00:00 2026-05-13T07:35:04+00:00

I am trying to implement Custom Error handling via Action Filter Attributes. My code

  • 0

I am trying to implement Custom Error handling via Action Filter Attributes.

My code is as follows:

[HandleError (Order = 2)]
[HandleError (Order = 1, ExceptionType = typeof(NullReferenceException), View = "CustomError")]
public class ArticlesController : Controller
{

    public object OhDearACrash()
    {
        throw new Exception("Oh Dear");
    }

    public ActionResult NullRefCrash()
    {
        throw new NullReferenceException();
    }

    public ActionResult ThrowNotImplemented()
    {
        throw new NotImplementedException();
    }

OhDearACrash and ThrowNotImplemented are both picked up by [HandleError] which renders the error message via Error.aspx located in Views/Shared.

For example with OhDearACrash:

Message = <%= ViewData.Model.Exception.Message %>

renders

Message = Oh Dear

NullRefCrash is picked up by the [HandeError] that deals with an ExceptionType = typeof(NullReferenceException).

When CustomError attempts to render the error message using

Message = <%= ViewData.Model.Exception.Message %>

the ViewData.Model is null and an exception is raised

System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."

To create CustomError.aspx I copied Error.aspx and pasted to my newly created Views/Error and renamed to CustomView.aspx.

Since Error.aspx and CustomError.aspx are essentially the same how is this occuring?

Edit:

I created a Test Project that only contains the above and the CustomError.aspx view works perfectly fine – Is there anyway to debug my existing project to find the issue?

  • 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-13T07:35:05+00:00Added an answer on May 13, 2026 at 7:35 am

    I just tried this on ASP.NET MVC 1.0 and I’m getting the correct behavior.

    Is it possible that you have another filter somewhere else that is running and changing the error somehow?

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

Sidebar

Related Questions

I am trying to implement Error handling using Action Filters Attributes as per ScottGu's
I'm trying to create a custom webpart. To implement error handling I would like
im trying to implement a custom error page, what i want to be able
I'm trying to implement a decorator for custom error pages in web2py as per
I'm trying to implement this accepted solution for displaying a custom error message: https://stackoverflow.com/a/5229581/141172
I'm trying to implement a custom class for dataannotations that retrieves error messages from
I am trying to implement some custom security code into SSRS 2008 (not R2)
I was trying to implement custom validation attribute by inheriting from ValidationAttribute and found
I'm trying to implement a custom field type for my Symfony2 forms but for
I'm trying to implement a custom route in rails match '/:slug' => products#get_by_slug, :as

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.