Tuesday, 30 June 2015

What is routing in MVC (.Net)?

Routing helps you to define a URL structure and map the URL with the controller.

         For instance lets take one example. My Controller name is Static and Method name is Whoweare. So we want to display in URL like "http://localhost/Static/who-we-are/", Below is the code that you show of how to map that URL with controller and action.

routes.MapRoute(
               name: "Whoweare",
               url: "who-we-are",
               defaults: new { controller = "Static", action = "Whoweare", id = UrlParameter.Optional }
           );

No comments:

Post a Comment