Write the below code in global.asax file in Application_Error Method.
StringBuilder errMessage = new StringBuilder();
Exception ex = Server.GetLastError();
if (ex is HttpException)
{
HttpException checkException = (HttpException)ex;
switch (checkException.GetHttpCode())
{
case 403:
{
errMessage.Append("You are not allowed to view that page.");
break;
}
case 404:
{
errMessage.Append("The page you requested cannot be found.");
break;
}
}
}
we can number of http code here.
No comments:
Post a Comment