Custom 500 error page not working correctly

Gleb Itenberg asked on January 30, 2019 11:54

I'v configure custom error pages. 404 error page works well but I have a problems with 500 error page. Here is my web config sections:

<customErrors mode="On" redirectMode="ResponseRewrite">
  <error statusCode="404" redirect="/Error404" />
  <error statusCode="500" redirect="/Error500" />
</customErrors>


<httpErrors errorMode="Custom" existingResponse="Auto">
    <remove statusCode="404" subStatusCode="-1" />
    <remove statusCode="500" subStatusCode="-1" />
    <clear/>
    <error statusCode="404" path="/Error404" responseMode="ExecuteURL" prefixLanguageFilePath="" />
    <error statusCode="500" path="/Error500" responseMode="ExecuteURL" prefixLanguageFilePath=""/>
</httpErrors>

But I'm getting simple page "Server Error in '/' Application."

If I change redirectMode="ResponseRewrite" to redirectMode="ResponseRedirect" than I'm getting my error page but url changes and lloks like 'error500/?aspxerrorpath=/CMSPages/PortalTemplate.aspx'. I need to avoid Url changes.

How can I get 500 error page work?

   Please, sign in to be able to submit a new answer.