Search code examples
asp.netvb.netasp.net-mvc-3maproute

MapRoute And Master Page (MVC3) - request not working


Good Afternoon,

I have a web application (MVC3) which has master page.

I have the following link localhost/home/index?Id=10

In own master, when I make a request("id") the value returned is 10.

When implemented the route. For the link to become localhost/home/index/10 In the master page of the return request("id") is now empty.

routes.MapRoute("index", "home/index/{id}", New With {.controller = "Home", .action = "index"}, New With {.id = "\d+"})

How can I fix this request?


Solution

  • If you are using routes, then you need to request the value associated to your route token:

    this.Request.RequestContext.RouteData.Values["id"]