Why ViewContext after RenderAction PartialView is changed? Route is lost

312 Views Asked by At

I'm trying to implement dynamic navigation inside of web project using MVC4. All of my dynamic parts of project are displayed as partial views rendered from controller. Now I have the situation where the initial page ViewContext is not available for the Pager extension inside the PartialView, the Routes in pager rendered as domain.controller.action?pagesize=20&page=2 instead of domain/about/presscenter/news?pagesize=20&page=2. Page debug shows that I got correct ViewContext before I RenderAction, but when it hits the Pager extension it is lost. Where do I go wrong?

1

There are 1 best solutions below

1
Roman On

My Pager renders itself accepting as parameter ViewContext needed to UrlHelper.GenerateUrl() method. So I had to pass the parent ViewContext to Pager like:

@Html.Pager(Model.PagingFilteringContext, ViewContext.ParentActionViewContext)