protected void Application_Error(object sender, EventArgs e) { Exception exception = Server.GetLastError(); HttpException httpexception = exception as HttpException; string action; if (httpexception != null) { switch (httpexception.GetHashCode()) { case 404: action = "HttpError404"; break; case 500: action = "HttpError405"; break; default: action = "General"; break; } } action = "HttpError404"; Response.Redirect(string.Format("~/Error/{0}/", action)); }