// IN Global.asax Under Application_Error
// IN web.config file Under
void Application_Error(object
sender, EventArgs e)
{
//////////// Code that runs when an unhandled error occurs
//Response.Redirect("~/Error Page Not Found");
Exception ex = Server.GetLastError();
Application["TheException"]
= ex; //store the error for later
Server.ClearError(); //clear the error so we
can continue onwards
Response.Redirect("~/Error Page Not
Found"); //direct user to error page
}
// IN web.config file Under
<system.web>
<!--<customErrors
mode="Off"></customErrors>-->
<customErrors mode="RemoteOnly" defaultRedirect="~/Error Page Not
Found"></customErrors>
</system.web>
<system.webServer>
<httpErrors errorMode="Custom" defaultResponseMode="Redirect">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="~/Error Page Not Found"
responseMode="Redirect" />
</httpErrors>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
No comments:
Post a Comment