1

Simple question: If I've got a generic Error.aspx page in my Shared folder (and the requisite HandleError on my controller). How do I show the exception message that triggered it?

This Scott Gu post states that the functionality should be in the default Error.aspx generated with new projects, but that was Preview 4, and I'm assuming that fell out with the v1.0 release.

1 Answer 1

6

ASP.NET MVC HandleError Attribute, Custom Error Pages and Logging Exceptions

ASP.NET has a nice web.config setting that configures custom errors. This property is exposed via MVC, so we can set up our config to show friendly errors to remote users only:

<customErrors mode="RemoteOnly" />
Sign up to request clarification or add additional context in comments.

2 Comments

Good article. To complete the loop, I'm overriding OnException and adding the exception message to a TempData variable so I can show it on the Error.aspx page. Thanks.
You should never ... and I stress never ... under any circumstance reveal the details of an exception to your users. Also, you'll need to use the [HandleError] action filter on your controller(s) or class(s) as well. msdn.microsoft.com/en-us/library/dd410203.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.