我正在尝试访问复合控件中的路由数据,以根据用户浏览到的部分更改图像的目录查找。
例如:http://www.mysite.com/photos/palmtrees
在这种情况下,{palmtree}= {id},我想在复合控件中访问它。
我读过类似的要求,但似乎get RequestContext只能返回null?
// this.Context = HttpContext.Current;
HttpContextBase htb = new HttpContextWrapper(this.Context);
RequestContext rc = new RequestContext(htb, RouteTable.Routes.GetRouteData(htb));
// rc -> is always NULL?有没有更简单的方法让RouteData在我的控制范围内?
发布于 2012-01-22 00:28:42
在路由之间跳转不在路由上下文中,这意味着RouteData永远不可用。
确保当用户单击按钮将其带到/photo/{id}时,路由的上下文将被激活。
不使用MVC,这是一个Web窗体项目。
https://stackoverflow.com/questions/8952941
复制相似问题