You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
Repository navigation
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
I have a PagingController with an Index action method, and the view exists at Views/Paging/Index.cshtml
My Index ActionMethod looks like this:
public IActionResult Index(int page = 1)
{
var currentPageNum = page;
var offset = (DefaultPageSize * currentPageNum) - DefaultPageSize;
var model = new ProductListViewModel();
model.Products = this.allProducts
.Skip(offset)
.Take(DefaultPageSize)
.ToList();
model.Paging.CurrentPage = currentPageNum;
model.Paging.ItemsPerPage = DefaultPageSize;
model.Paging.TotalItems = allProducts.Count;
return View(model);
}
When you click the PagingDemo1 link in the navigation the url is http://localhost:55769/pager and it finds the Index view as it should. However when I click one of the pagination links which passes a parameter for the page number for example http://localhost:55769/pager/4
I get an error:
InvalidOperationException: The view 'Index' was not found. The following locations were searched:
/Views/Shared/Index.cshtml
So for some strange reason it in not looking in the right place for the view, it should look in Views/Paging but it only looks in Views/Shared
As I recall it worked fine in preview2 and it also worked in 1.x. No other code changes have been made except updating to 2.0 dependencies and making the Program.cs and Startup.cs more like what the latest project templates provide.
I'm moving this to the MVC repo where we can track the fix for this on our side. We don't intend for the 'pages' view search behavior to kick in unless you are using pages.
Activity
rynowak commentedon Aug 17, 2017
From @davidfowl on August 16, 2017 17:32
Change the page variable name to p in the route definition and method. See if that works.
I believe we have an unintentional breaking change here
rynowak commentedon Aug 17, 2017
From @joeaudette on August 16, 2017 17:43
@davidfowl I confirm that changing the variable to p solved it
rynowak commentedon Aug 17, 2017
From @joeaudette on August 16, 2017 17:44
@davidfowl but doing that also changed the url from http://localhost:55769/pager/4 to http://localhost:55769/pager?page=4
which wasn't desired
rynowak commentedon Aug 17, 2017
From @davidfowl on August 16, 2017 18:4
There's another work around but that shouldn't happen with this one. Did you update the method parameter as well?
rynowak commentedon Aug 17, 2017
From @joeaudette on August 16, 2017 18:8
ok, changing the method param and the asp-route param to p as well solved it and kept the desired url structure
rynowak commentedon Aug 17, 2017
I'm moving this to the MVC repo where we can track the fix for this on our side. We don't intend for the 'pages' view search behavior to kick in unless you are using pages.
eat-sleep-code commentedon Aug 17, 2017
FYI this has been logged as a bug: #6660
pranavkm commentedon Aug 24, 2017
Yup @eat-sleep-code , this is a dup of #6600. Closing this since we've other work items tracking for the patch and 2.1.0 releases.