In ASP.NET MVC, URL pattern is completely different as compare to the ASP.NET application URL pattern, So lets learn about the ASP.NET MVC routing.
What is routing in ASP.NET MVC ?
Routing is the concept in ASP.NET MVC which is used to define the URL pattern for the ASP.NET MVC application incoming user request.
There are two types of routing supported by ASP.NET MVC
- Conventional based routing
- Attribute routing
The default routing in ASP.NET MVC is a conventional routing which is get added in RouteConfig.cs file when we create ASP.NET MVC application, These type of routing defined in RouteConfig.cs file .
The following is the default routing
The routing which is defined on controller or action level is called as attribute routing . These type of routing is only supports in MVC 5 version onward
- RouteCollection class is used for routing which uses the System.Web.Routing namespace
- ASP.NET MVC 5 supports two types of routing that is conventional and attribute routing
- Conventional based is the default routing in ASP.NET MVC
- Attribute routing can be defined on controller as well as action level
- All routes should be registered into the Global.asax file .
- Every ASP.NET MVC application must have at least one routing defined
- We can define multiple routing in single application in this case it executed sequence wise as it defined.
- If we are defining two route templates then the route name must be different across the application level