根据文章“
What’s New in ASP.NET MVC5”,您必须将其添加到RegisterRoutes()方法才能使用属性路由:
routes.MapMvcAttributeRoutes();
…所以现在的方法是:
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapMvcAttributeRoutes(); routes.MapRoute( name: "Default",url: "{controller}/{action}/{id}",defaults: new { controller = "Home",action = "Index",id = UrlParameter.Optional } ); }
那么,如果有的话,为我做什么呢?