I have ASP.NET set up to use the CustomErrors functionality:
<customErrors mode="On" defaultRedirect="~/ErrorPages/500.aspx" redirectMode="ResponseRewrite">
<error statusCode="404" redirect="~/ErrorPages/404.aspx" />
<error statusCode="500" redirect="~/ErrorPages/500.aspx" />
</customErrors>
Everything works nice, and the relevant error pages are shown when appropriate.
Except in the following two cases:
1) When there is an exception thrown in global.asax
:
public class MvcApplication : System.Web.HttpApplication
{
protected void Application_Start()
{
throw new ApplicationException("Exception in Application_Start()");
}
}
2) When there is a syntax error in web.config
In both cases, I don't see my pretty 500.aspx
page. Instead, I see the standard ASP.NET yellow screen of death, with the following message:
Server Error in '/MvcErrorHandling' Application.
Runtime Error
Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed.
How can I get ASP.NET or IIS to show a custom error page (a pretty one, instead of the YSOD) in the above two scenarios?
Thanks in advance for any input :)