ASP.NET MVC: Route any error requests to my custom page
In ASP.NET MVC, I need to route any error requests to my custom page, can I use this way?
routes.MapRoute(
"Default", // Route name
"{*pathInfo}",
new { controller = "Home", action = "NotFound" }
)开发者_如何学Python;
And, are there any better way to implement this?
http://weblogs.asp.net/fredriknormen/archive/2007/11/22/asp-net-mvc-framework-handling-exception-by-using-an-attribute.aspx
In the global.asax:
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute() { View = "YourView" });
}
精彩评论