ASP. net mvc can mark the action to be processed with handleerror,
The Web. config configuration is as follows:
<Customerrors mode = "on" defaultredirect = "~ /Account/error ">
<Error statuscode = "403" Redirect = "~ /Account/nopermission "/>
<Error statuscode = "404" Redirect = "~ /Account/nopage "/>
</Customerrors>
Extended handleerror
Public class errorfilter: handleerrorattribute
{
Public override void onexception (system. Web. MVC. exceptioncontext filtercontext)
{
If (filtercontext. httpcontext. iscustomerrorenabled)
{
Filtercontext. exceptionhandled = true;
}
Base. onexception (filtercontext );
// Override the 500 Error
Filtercontext. httpcontext. response. statuscode = 200;
}
Private Static void raiseerrorsignal (exception E)
{
VaR context = httpcontext. Current;
// Using. elmah. errorsignal. fromcontext (context). Raise (E, context );
}
}