This post shows you How to fix 'Unable to resolve service for type Microsoft AspNetCore Session ISessionStore' in ASP.NET Core.
InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Session.ISessionStore' while attempting to activate 'Microsoft.AspNetCore.Session.SessionMiddleware'.
Open the Startup.cs class, then add the following c# code to ConfigureServices method.
services.AddMvc().AddSessionStateTempDataProvider();
services.AddSession();
You can solve the problem 'Unable to resolve service for type Microsoft AspNetCore Session ISessionStore' as shown below.
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().AddSessionStateTempDataProvider();
services.AddSession();
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Latest);
}