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?
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.