开发者

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" });
  }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜