I am trying to create custom error pages for my application and it's working for the most part, but not for 403
errors.
My Web.config:
<customErrors mode="On" defaultRedirect="~/Error">
<error statusCode="404" redirect="~/Error/NotFound" />
<error statusCode="500" redirect="~Error/InternalServer" />
<error statusCode="403" redirect="~Error/Forbidden" />
</customErrors>
I have an ErrorController
that is delegating these requests. When the 404
hits, it displays the custom error page, but 403
does not. I am getting the default IIS 403 - Forbidden
page even though I have set a custom error page for it. I've had a look around and tried to use <httpErrors>
instead which just seems to give me a blank page everytime.
Here is my Global.asax
if it's any help:
void Application_Error(object sender, EventArgs e)
{
Exception exc = Server.GetLastError();
if (exc is HttpUnhandledException)
{
// Pass the error on to the error page.
Server.Transfer("ErrorPage.aspx?handler=Application_Error%20-%20Global.asax", true);
}
}