In my ASP.NET web application, I have defined custom error pages in my web.config file as follows:
Add redirectMode="ResponseRewrite" in the Custom Error like this,
redirectMode="ResponseRewrite"
this solution works for me.