Routing helps you to define a URL structure and map the URL with the controller.
Let us try to understand this with an example, - when we want that when a user types "http: // localhost / View / ViewCustomer /", it goes to the "Customer" controller and the DisplayCustomer action Invites you. This is defined by adding an entry into the routes collection using the map_route function. Below is the underlined code which shows how the URL structure and mapping with controller and action are defined.
routes.MapRoute(
"View", // Route name
"View/ViewCustomer/{id}", // URL with parameters
new { controller = "Customer", action = "DisplayCustomer",
id = UrlParameter.Optional }); // Parameter defaults
And the route mapping code is written in "RouteConfig.cs" file and registered using "global.asax" application start event.
Liked By
Write Answer
What is routing in MVC?
Join MindStick Community
You have need login or register for voting of answers or question.
Anonymous User
15-Oct-2019Routing helps you to define a URL structure and map the URL with the controller.
Let us try to understand this with an example, - when we want that when a user types "http: // localhost / View / ViewCustomer /", it goes to the "Customer" controller and the DisplayCustomer action Invites you. This is defined by adding an entry into the routes collection using the map_route function. Below is the underlined code which shows how the URL structure and mapping with controller and action are defined.
And the route mapping code is written in "RouteConfig.cs" file and registered using "global.asax" application start event.