In my MVC application I have enabled the custom errors in the web.config. I want all errors to redirect to one page.
<customErrors mode="On" redirectMode="ResponseRewrite" />
This redirects to the ~/Views/Shared/Error.cshtml
page just fine when I do
throw new Exception();
But when I surf to site/Home/Bla
it redirects me to an IIS general 404 error page and not my custom one.
I tried to add
private void Application_Error(object sender, EventArgs e)
{
Response.TrySkipIisCustomErrors = true;
}
to the Global.asax
, but to no avail.
Does anybody know what might be the problem? (If you need more information, then aks and ye shall receive.)