3
I have a problem, always when I will compile the solution this giving error:
System.Invalidoperationexception: 'Unable to resolve service for type 'Microsoft.AspNetCore.Session.Isessionstore' while attempting to Activate 'Microsoft.AspNetCore.Session.Sessionmiddleware'.'
Arquivo Startup.Cs
// This method gets called by the runtime. Use this method to add services to the container.
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);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseSession();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
How’s your Startup.Cs file going??
– Diego Pupato
Dear @Hiago-Orrêa please adjust your question, it has formatting problems. Don’t just use the image to show the error, copy and paste it into the question, it will make future search easier for other members.
– Tiedt Tech
As requested I made the change.
– Thiago Corrêa