I have an index view that takes the page parameter like so:
/News?page=2
But in the layout for that view I have this childaction:
@{Html.RenderAction("Index", "Comments", new {page=1, pagesize = 10});}
But the querystring “page” remains 2.. how come? And how to override page for the childaction?
That’s because the child action first looks at the original request query string when binding for values and after that the one passed as argument to theRenderActionhelper. You could use a different name for this parameter to avoid this ambiguity.UPDATE:
Unable to reproduce the behavior you are describing.
Controller:
View (
~/Views/Home/Index.cshtml):When querying
/Home/Index?page=5the correct value 1 is shown and thepageparameter in the child action is 1.Obviously if inside your child action you are fetching this value manually from the request it won’t work but that’s not something you should be doing anyways: