Answer: Instead of showing File Not Found error message we can handle this error with code in global.asax file. We need to write code in Application_Error event as:-
void Application_Error(object sender,EventArgs e)
{
//Code that runs when an unhandled error occurs
Exception Ex = Server.GetLastError().GetBaseException();
if (ex.GetType() == typeof(System.IO.FileNotFoundException))
{
Response.Redirect("Default404.aspx");
}
}
Asked In: Many Interviews |
Alert Moderator