Sunday, June 24, 2018

How to enable Attribute Routing?

Just add the method — “MapMvcAttributeRoutes()” to enable attribute routing as shown below
public static void RegistearRoutes(RouteCollection routes)
{
routes.IgnoareRoute(“{resource}.axd/{*pathInfo}”);
//enabling attribute routing
routes.MapMvcAttributeRoutes();
//convention-based routing
routes.MapRoute
(
name: “Default”,
url: “{controller}/{action}/{id}”,
defaults: new { controller = “Customer”, action = “GetCustomerList”, id = UrlParameter.Optional }
);
}