I am trying to handle 404 page not found exception in mvc and i just want to know the right approach to handle page not found. this is how i handle the 404 page not found exception
protected void Application_Error()
{
ShowCustomErrorPage(Server.GetLastError());
}
private void ShowCustomErrorPage(Exception exception)
{
var httpException = exception as HttpException;
if (httpException.GetHttpCode() == 404)
{
Response.Redirect("PagenotFound");
}
}
is this the right approach !!!