I use Asp.net 4 C# and IIS 7 locally and IIS 7.5 on Production Server.
I need display Custom Error Pages. At the moment I use some logic in my Global.asax to bypass IIS default pages.
Locally using IIS 7 I was able to successfully display CustomPages but on production (IIS 7.5) Server defaults IIS pages persists.
I use Response.TrySkipIisCustomErrors = true;
but on Production Server does not work.
Could you point me out a solution to this problem?
My code in Global.Asax
Application_Error
Response.TrySkipIisCustomErrors = true;
if (ex is HttpException)
{
if (((HttpException)(ex)).GetHttpCode() == 404)
{
Server.Transfer("~/ErrorPages/404.aspx");
}
}
// Code that runs when an unhandled error occurs.
Server.Transfer("~/ErrorPages/Error.aspx");