如何实现属性路由

启用属性路由要启用属性路由,请在配置期间调用 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 }
);
}