문제

I'd very appreciate of someone could advise on my problem with pagination. My controller:

   public ActionResult Index(string humanID, int? page)
    {
        int pageSize = 7;
        int pageNumber = (page ?? 1);

        AHuman human = _unitOfWork.HumansRepo.GetById(humanID);
        ViewBag.HumanID = human.ID;

        return PartialView(human.StatisticalCards.ToList().ToPagedList(pageNumber, pageSize));

    }

My View:

    @model PagedList.IPagedList<PolyclinicStatisticalCard>
    @using PagedList.Mvc; 
<div>
    @foreach (var card in Model)
    { //displaying data }

Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) из @Model.PageCount

@Html.PagedListPager(Model, page => Url.Action("Index", new { humanID = ViewBag.HumanID, page = page }))
</div>

I see my paging control below the displayed data and when i try to go to the second page, my Index ActionResult starts cycling. The browser says there is circular redirection. May it be a problem with partial view? Thanks in advance!

도움이 되었습니까?

해결책

That is not a solution, but may be helps you to find real error. You are receiving cycling error not because of PagedList or ActionResult. It means that you have error somethere on a page, system is trying to readress you on Error page, but this page also returns error. So you are receiving cycling readressing error. If you want to see a real error, just deactivate customErrors in your Web.config:

<system.web>
        <customErrors mode="Off"/>
    </system.web>

It will stop redirection to Error page and you'll see your real error. After just delete this expression.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top