Answer the question
In order to leave comments, you need to log in
Error handling in Asp.net MVC?
There is such an error handler in Global.asax.cs
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 = "HttpError";
break;
default:
action = "HttpError";
break;
}
Session["error"]=exception.Message;
// clear error on server
Server.ClearError();
Response.Redirect(String.Format("~/Home/HttpError/?message={0}", exception.Message));
}
}
throw new HttpException(404, "not found");
Answer the question
In order to leave comments, you need to log in
When I click Continue, my error page appears and everything is fine .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question