Here is my web.config custom errors configuration:
<system.web>
<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/400.aspx">
<error statusCode="404" redirect="~/404.aspx" />
<error statusCode="500" redirect="~/500.aspx" />
<error statusCode="400" redirect="~/400.aspx" />
</customErrors>
</system.web>
<system.webServer>
<httpErrors errorMode="Custom">
<remove statusCode="404"/>
<error statusCode="404" path="404.html" responseMode="File"/>
<remove statusCode="500"/>
<error statusCode="500" path="500.html" responseMode="File"/>
<remove statusCode="400"/>
<error statusCode="400" path="400.html" responseMode="File"/>
</httpErrors>
</system.webServer>
Works fine for 404. But this localhost:44303/< script >< /script > returns: Runtime Error.
As well throwing a new Exception from an action intentionally redirects to mvc error page, which I want to override with my 500.aspx