Home > DeveloperSection > Forums > How to Map URL with controller
Anupam Mishra

Total Post:135

Points:949
Posted on    February-03-2016 10:17 PM

 ASP.Net C#  ASP.Net  ASP.NET MVC 
Ratings:


 1 Reply(s)
 286  View(s)
Rate this:
Hi Everyone,
I want that when we types http://localhost/View/View Student/, it goes to the “Student” Controller and invokes the DisplayStudent action. Please give me solution, how to map this action with controller,when we types a such type url.
Thank you.


Anupam Mishra

Total Post:135

Points:949
Posted on    February-03-2016 11:12 PM

For solving above problem, we have adding an entry in to the routes collection using the maproute function. In Below i have underlined code which shows how the URL structure and mapping with controller and action is defined.

routes.MapRoute(
               "View", // Route name
               "View/ViewStudent/{id}", // URL with parameters
               new { controller = "Student", action = "DisplayStudent", 
id = UrlParameter.Optional });


Don't want to miss updates? Please click the below button!

Follow MindStick