I am creating an ASP.NET core study project, and when using the PagedList.Core
paging library, the following error is occurring when running the dotnet run
command:
Startup.cs (49.35): error CS0246: The name of the type or namespace "IActionContextAccessor" can not be found (is it missing a using directive or an assembly reference?) [C: \ projects \ net \ osnet \ osnet.csproj]
Startup.cs (49,59): error CS0246: The name of the type or namespace "ActionContextAccessor" can not be found (is there a missing directive or an assembly reference?) [C: \ projects \ net \ osnet \ osnet .csproj]The build failed. Correct the build errors and run again.
What could it be?
My method ConfigureServices
of file Startup.cs
looks 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
}