1. Error 401 Authorization
public class Global : HttpApplication
{
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
}
protected void Application_EndRequest()
{
var context = new HttpContextWrapper(Context);
if (context.Response.StatusCode == 401)
{
context.Response.Redirect("~/Home/Error2");
}
}
}
2. Error 404
<customErrors mode="On">
<error statusCode="404" redirect="~/Home/Error"/>
</customErrors>
No comments:
Post a Comment