//////////////////////// web.config file
//////////////////////// web.config file
<!--<customErrors mode="On"
defaultRedirect="~/Error-page"> </customErrors>-->
--------------------------------------------------
<system.web>
<webServices>
<protocols>
<remove name="Documentation"/>
</protocols>
</webServices>
</system.web>
--------------------------------------------------
<system.webServer>
<httpErrors errorMode="Custom" defaultResponseMode="Redirect">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="~/Path/Error-page"
responseMode="Redirect" />
<remove statusCode="403" subStatusCode="-1" />
<error statusCode="403" prefixLanguageFilePath="" path="~/Path/Error-page"
responseMode="Redirect" />
<remove statusCode="405" subStatusCode="-1" />
<error statusCode="405" prefixLanguageFilePath="" path="~/Path/Error-page"
responseMode="Redirect" />
</httpErrors>
</system.webServer>
//////////////////////// web.config file
protected void
Application_Error(object sender, EventArgs e)
{
Exception exception = Server.GetLastError();
Response.Clear();
HttpException httpException = exception as HttpException;
if (httpException != null)
{
string action;
switch (httpException.GetHttpCode())
{
case 404:
// page not found
action = "~/Error-page";
break;
case 500:
// server error
action = "~/Error-page";
break;
default:
action = "~/Error-page";
break;
}
// clear error on server
Server.ClearError();
Response.Redirect("~/Error-page");
}
}
No comments:
Post a Comment