Routing is way that eliminates needs of mapping each and every URL with a physical file. Routing provide a way that’s enable developer to define URL pattern that maps to the request handler. This request handler can be a file (In asp.net application, its .aspx file) or class (In MVC its Controller class and Action method).
For example, http//domain/Employee can be mapped to http://domain/EmployeeInfo.aspx in ASP.Net Web application. And http//domain//Employee same URL mapped with controller and action method in MVC.
Every MVC application must be configured by MVC framework by default. And also every MVC application must register(configure) at least one route. You can configure route in RouteConfig class, RouteConfig class is in RouteConfig.cs under App_Start directory(folder). Following line of code illustrate how to configure route in RouteConfig.cs file in MVC.
In above line of code 'BasicTut' is Controller, “Index” is the Action method and, id is a parameter that can be optional.
We can also configure (register) custom a route by using the extension method of MapRoute.
At least two parameters require red in MapRoute. The Default parameter is optional.
You can also register multiple custom routes with different names. below of codes that illustrate how to register multiple route routes
Leave Comment