I've been following this guide for the HandleError attribute: blogs.msdn.com which I use like this (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)
fails because of a System.Data.EntityException.
I've put the ErasErrorPage view in my Shared folder and I've added <customErrors mode="On"/>
but the ErasErrorPage does not show up. All I get when the error occurs is a yellow screen of death saying:
Obviously, setting the mode to "Off" or "RemoteOnly" doesn't solve the problem.
Anyone has an idea why this doesn't work?
EDIT
If I surf directly to http://localhost:3527/Account/Index, I do get the correct ErasErrorPage, but I don't want that. I want the website to automaticly redirect to that page when an exception is thrown somewhere. Is this possible?
EDIT2
I've put the [HandleError(View="ErasErrorPage")]
attribute right before every single Public ActionResult methodName() { ... }
method, and I still get the Yellow Screen of Death saying I need to change the mode to "Off" or "RemoteOnly"...