Why can't I reference to PaginatedList.cs in index.cshtml.cs?

365 Views Asked by At

A friend and I are following this tutorial but changing things to match our project: https://learn.microsoft.com/en-us/aspnet/core/data/ef-rp/sort-filter-page?view=aspnetcore-3.0

We have checked everything multiple times and are getting the following errors. We are having problems with referencing the PaginatedList.cs class which is in the VitekSite project. We are trying to refer to the PaginatedList.cs class from the index.cshtml.cs class.

My problem starts with the first error when I delete the following:

public IList<Customer> Customers { get; set; }

and replace it with the following:

public PaginatedList<Customer> Customers { get; set; }

The public PaginatedList can't be referred to but all my namespaces and using references are correct.

I get the following two errors. If I can fix the first one I think the second one will be solved.

  1. Error CS0246 The type or namespace name 'PaginatedList<>' could not be found (are you missing a using directive or an assembly reference?) VitekSite C:\Users\ahmad\source\repos\VitekSite\VitekSite\Pages\Customers\Index.cshtml.cs 29 Active

  2. Error CS0103 The name 'PaginatedList' does not exist in the current context VitekSite C:\Users\ahmad\source\repos\VitekSite\VitekSite\Pages\Customers\Index.cshtml.cs 72 Active

So to summarize, my problem is that I can't refer to PaginatedList in the index.cshtml.cs class.

Here is a link of the code which we have so far.

https://github.com/ahma0307/VitekSite6

UPDATE: Everything is working now but we are getting the following warnings Hmm. Everything is working but we are getting the following warnings for some reason.

C:\Users\EAL\Source\Repos\VitekSite6\VitekSite\VitekSite.csproj : warning NU1701: Package 'PagedList 1.17.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.0'. This package may not be fully compatible with your project. 1>C:\Users\EAL\Source\Repos\VitekSite6\VitekSite\VitekSite.csproj : warning NU1701: Package 'PagedList.Mvc 4.5.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.0'. This package may not be fully compatible with your project. 1>VitekSite -> C:\Users\EAL\Source\Repos\VitekSite6\VitekSite\bin\Debug\netcoreapp3.0\VitekSite.dll

Update 2: We have tried removing the ASP.NET (Classic) Reference but when we do that the site stops working Image of error when running site

0

There are 0 best solutions below