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.
Join MindStick Community
You need to log in or register to vote on answers or questions.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
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.
And the route mapping code is written in "RouteConfig.cs" file and registered using "global.asax" application start event.