Advertise with us

How to Map URL with controller

Posted by  Anupam Mishra
 1106  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.
  1. Re: How to Map URL with controller

    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.

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