简体   繁体   English

局部视图中的原始路线参数

[英]Original Route parameters in partial view

I'm trying to get the original route parameters in a partial view, more concrete: I have a view with following code: 我试图在局部视图中获取原始路线参数,更具体地讲:我有一个包含以下代码的视图:

@Html.Action("List", "Forum", new { obj = Model.Project})

I have a forumcontroller with following method: 我有一个使用以下方法的forumcontroller:

    public PartialViewResult List(IForumTopic obj)
    {
        return PartialView(obj.ForumTopics);
    }

Now I want the route data of the original request: if i use the url : /home/1/Forum/List then List is the method, 1 is the Id, and home is the controller, but if i do this: 现在我想要原始请求的路由数据:如果我使用url:/ home / 1 / Forum / List,则List是方法,1是ID,而home是控制器,但是如果我这样做:

ViewContext.RequestContext.RouteData.Values["controller"].ToString();

the value is Forum and not Home, is there a way to get Home, and the Id from de route parameters? 值是“论坛”而不是“主页”,是否有办法获取“主页”,以及从路由参数获得的ID?

我自己找到了它,可以执行以下操作: this.Request.RequestContext.RouteData.Values["controller"].ToString();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM