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:
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:
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?
I found it myself, you can do the following:
this.Request.RequestContext.RouteData.Values["controller"].ToString();