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?
Asked
Active
Viewed 305 times
1 Answers
0
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)

Roman
- 665
- 1
- 9
- 24
-
It is strange! But the 'var url = UrlHelper.GenerateUrl(null, null, null, routeValues, RouteTable.Routes, viewContext.RequestContext, true);' inside my pager removes the last segment of URLs it renders, like domain/about/presscenter?pagesize=20&page=2 instead of domain/about/presscenter/news?pagesize=20&page=2. – Roman Nov 07 '13 at 12:35