30
我使用默认路由mvc2,如{controller}/{action}/{id}
。我想在我看来访问那个id
字段。我怎么能不用TempData
和ViewData
?在视图中访问路由值Mvc.net
如果我有一个url像 http://server-name/home/edit/14
我需要值"14"
在视图中。
我使用默认路由mvc2,如{controller}/{action}/{id}
。我想在我看来访问那个id
字段。我怎么能不用TempData
和ViewData
?在视图中访问路由值Mvc.net
如果我有一个url像 http://server-name/home/edit/14
我需要值"14"
在视图中。
您可以访问使用ViewContext属性路线数据:
<%= ViewContext.RouteData.Values["id"] %>