MVC3 HandleError does not show error page

I follow this guide for the HandleError: blogs.msdn.com attribute that I use this way (AccountController):

[HandleError(View="ErasErrorPage")]
        public ActionResult Index()
        {
            ViewBag.admins = _accountMapper.GetAdmins(false);
            ViewBag.members = _accountMapper.GetMembers(false);
            ViewBag.Countries = _countryMapper.GetCountries();

            return View();
        }

This code throws an exception because _accountMapper.GetAdmins(false)it fails because of a System.Data.EntityException exception.

I put the ErasErrorPage view in my shared folder and I added <customErrors mode="On"/>, but ErasErrorPage is not displayed. All I get when an error occurs is a yellow screen of death saying:

Error Obviously, setting the mode to “Off” Or "Remote Control" does not solve the problem.

Does anyone have an idea why this is not working?


EDIT

http://localhost:3527/Account/Index, ErasErrorPage, . , - , - . ?


EDIT2

[HandleError(View="ErasErrorPage")] Public ActionResult methodName() { ... }, , , "." " "...

+3
3

, :

asp.net MVC3

, :

, . HandleError ( ). . .

+3

, ErasErrorPage . , , :

  • ASP.NET MVC 3 Visual Studio
  • ~/Views/Shared/ErasErrorPage.cshtml :

    @{
        Layout = null;
    }
    <!DOCTYPE html>
    <html>
    <head>
        <title>ErasErrorPage</title>
    </head>
    <body>
        <div>
            OOPS
        </div>
    </body>
    </html>
    
  • HomeContoller :

    public class HomeController : Controller
    {
        [HandleError(View = "ErasErrorPage")]
        public ActionResult Index()
        {
            throw new Exception("oops");
        }
    }
    
  • web.config put:

    <customErrors mode="On" />
    
  • /Home/Index = >

+3

, BaseController [HandleError(View = "Error")] Error Shared ( HandleErrorInfo), Index HomeController :

throw new Exception("Test exception");

.

ErrorView:

<div class="errorMessage">
    <h1 class="errorHeader">@Model.Exception.GetType().Name</h1>
    <cite class="errorAction">thrown in @Model.ControllerName @Model.ActionName</cite>
    <p class="errorMessage">thrown in @Model.Message</p>
</div>
+1

All Articles