在ASP.NET MVC中,我需要将任何错误请求路由到我的自定义页面,我可以使用这种方式吗?
routes.MapRoute(
"Default", // Route name
"{*pathInfo}",
new { controller = "Home", action = "NotFound" }
);
并且,有没有更好的方法来实现它?
答案 0 :(得分:0)
在global.asax中:
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute() { View = "YourView" });
}
答案 1 :(得分:0)