I have an MVC 2 web application that is nearing release. So far, I have had user errors disabled, but I would like them to work when I prepare the production.
I installed my web.config with the following:
<customErrors mode="On" defaultRedirect="/Error/">
<error statusCode="404" redirect="/Error/NotFound "/>
</customErrors>
404 works just fine, and NotFound is an action that directly translates into a view that simply displays a pretty standard 404 page using my own Site.Master file.
For anything other than 404, I want the user to be able to view exception details. (This is an internal application, and there is no security risk).
The Errordefault action is Indexset to return the view () that I defined. I can't figure out how to pass exception information into a view?
It looked promising:
http://devstuffs.wordpress.com/2010/12/12/how-to-use-customerrors-in-asp-net-mvc-2/
But when I use View with:
<%@ Page Title="" Language="C#"
MasterPageFile="~/Views/Shared/Bootstrap.Master"
Inherits="System.Web.Mvc.ViewPage<System.Web.Mvc.HandleErrorInfo>" %>
The error page itself causes an error because HandleErrorInfo is NULL. Obviously, the error in the user error causes MVC2 a number of problems, and the result is a yellow screen of death.
I assume that either I missed something on the blog or does not explain how to make HandleErrorInfo to be anything other than zero without setting the Error attribute for each of my controllers / actions.
, , MVC3 , , Razor . , . , , " MVC3".