2

下午好,

我有一个具有母版页的 Web 应用程序 (MVC3)。

我有以下链接 localhost/home/index?Id=10

在自己的主人中,当我发出请求(“id”)时,返回的值为 10。

实施路线时。让链接变成 localhost/home/index/10 在返回请求的母版页中(“id”)现在是空的。

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

我该如何解决这个请求?

4

1 回答 1

0

如果您正在使用路由,那么您需要请求与您的路由令牌关联的

this.Request.RequestContext.RouteData.Values["id"]
于 2012-07-28T20:07:18.190 回答