ASP.NET Core Pagination - Pagedlist.Core

Asked

Viewed 555 times

3

I am creating an ASP.NET core study project, and when using the paging library PagedList.Core, the following error is occurring while running the command dotnet run:

Startup.Cs(49,35): error CS0246: The namespace or type name "Iactioncontextaccessor" cannot be found (is a using directive or an Assembly reference missing?) [C: net osnet osnet osnet projects.csproj]
Startup.Cs(49,59): error CS0246: The type name or namespace "Actioncontextaccessor" cannot be found (is a using directive or an Assembly reference missing?) [C: net osnet osnet osnet projects.csproj]

A build failed. Fix build errors and run again.

What could be ?

My method ConfigureServices of the archive Startup.cs is like this:

public void ConfigureServices(IServiceCollection services)
    {
        services.Configure<CookiePolicyOptions>(options =>
        {
            // This lambda determines whether user consent for non-essential cookies is needed for a given request.
            options.CheckConsentNeeded = context => true;
            options.MinimumSameSitePolicy = SameSiteMode.None;
        });

        services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
       
        var connection = Configuration["ConexaoSqlite:SqliteConnectionString"];
        services.AddDbContext<OsNetContext>(options =>
            options.UseSqlite(connection)
        );
        // Add framework services.
        services.AddMvc();
        services.AddSingleton<IActionContextAccessor, ActionContextAccessor>(); // <= Add this
        
    }
  • 1

    Is there an error in the build?

  • Good morning buddy, the error in Build is the one mentioned in the question: Startup.Cs(49,35): CS0246 error: The type or namespace name "Iactioncontextaccessor" cannot be found (is missing a using directive or an Assembly reference?) [C: osnet osnet osnet projects] Startup.Cs(49,59): error CS0246: Type name or namespace "Actioncontextaccessor" cannot be found (using a directive or an Assembly reference is missing?) [C: net osnet osnet osnet.csproj projects] There was a build failure. Fix build errors and run again.

1 answer

1

Make sure your project is referencing Assembly Microsoft.AspNetCore.Mvc.Core.dll

The interface namespace is Microsoft.AspNetCore.Mvc.Infrastructure

Browser other questions tagged

You are not signed in. Login or sign up in order to post.