0 votes
in C Sharp by

Define attribute based routing in MVC?

1 Answer

0 votes
by

Attribute Routing was introduced in ASP.NET MVC 5. It allows developers to generate urls for controllers actions by adding Route Attributes to them.

This type of MVC routing uses attributes to define routes and gives developer more control over the urls of web application.In order to use Attribute Routing first you have to enable it by calling MapMvcAttributeRoutes during configuration.

//Configuring Attribute Routing in MVC.

public class RouteConfig
{
    public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
 
        routes.MapMvcAttributeRoutes();
    }
}

Related questions

0 votes
0 votes
asked May 14, 2020 in MVC Language by sharadyadav1986
0 votes
asked Jul 30, 2021 in C Sharp by DavidAnderson
...