HOW TO MAP URL WITH CONTROLLER

Anupam Mishra

Total Post:135

Points:949
Posted by  Anupam Mishra
 532  View(s)
Ratings:
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. Anupam Mishra

    Post:135

    Points:949
    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.


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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!