I trying to do something like that
First, Create a new mvc 3 project in visual studio 2010
Next, Turning on the custom error in the Views\Shared\Web.config
<system.web>
<customErrors mode="On"/>
...
And then, I put the Tag in the Index ActionResult, Home Controller
Public Class HomeController
Inherits System.Web.Mvc.Controller
<HandleError()> _
Function Index() As ActionResult
ViewData("Message") = "Welcome to ASP.NET MVC!"
Throw New InvalidOperationException
Return View()
End Function
Function About() As ActionResult
Return View()
End Function
End Class
Finally run the app, and always show the yellow message error. I review a lot of examples and always indicated that is correct, but doesn’t work.
I appreciate your help
You should do this in the main
~/web.configfile, not the one in~/Views/Shared/Web.config:Also ensure that
~/Views/Shared/Error.cshtmlis present as this will be the rendered view in case of an exception.And you no longer need to decorate your controller with the
<HandleError()>attribute as ASP.NET MVC 3 uses a global filter for this.