In Application the http status code errors are handled through web.config.
I have specified the http error code and respective path to show in case of http status error
<customErrors mode="On" redirectMode="ResponseRewrite" />
<httpErrors existingResponse="Replace" errorMode="Custom">
<clear/>
<remove statusCode="404"/>
<error statusCode="404" path="Themes\Patient6\Static\404.html" responseMode="File"/>
<remove statusCode="404" subStatusCode="980"/>
<error statusCode="404" subStatusCode="980" path="/patient.search/search/noresults" responseMode="ExecuteURL"/>
<remove statusCode="410"/>
<error statusCode="410" path="Themes\Patient6\Static\410.html" responseMode="File"/>
<remove statusCode="410" subStatusCode="990"/>
<error statusCode="410" subStatusCode="990" path="/forums/discuss/deleted" responseMode="ExecuteURL"/>
<remove statusCode="500"/>
<error statusCode="500" path="Themes\Patient6\Static\500.html" responseMode="File"/>
<remove statusCode="403"/>
<error statusCode="403" path="Themes\Patient6\Static\403.html" responseMode="File"/>
</httpErrors>
The above code is working fine for the given status code in httperrors but for the other error like 400, 502 the code is not handled so it shows the error explicitly.
Expected solution :
Is there any if-condition/Default-Path kind of solution to show custom error for given status code and 500 for other status code.
I tried the below workaround :
<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="/error-500" />
But it redirect to 500 for all the error status code which gives false information for the user.
I also tried this :
<httpErrors existingResponse="Replace" errorMode="Custom" defaultResponseMode="File" defaultPath="Themes\Patient6\Static\500.html">
But getting the below error for the above line
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.