如何正确处理ASP.NETMVC中的404?
使用URL路由:
routes.MapRoute( "Error", "{*url}", new { controller = "Errors", action = "NotFound" } // 404s);
在控制器本身中重写HandleUnKnownAction():
// 404s - handle here (bad action requestedprotected override void HandleUnknownAction(string actionName) { ViewData["actionName"] = actionName; View("NotFound").ExecuteResult(this.ControllerContext);}
守着星空守着你