ASP.NET MVC 6 AspNet.Session Errors - Unable to resolve service for type?

PlsBroSendHelp picture PlsBroSendHelp · Aug 7, 2015 · Viewed 19k times · Source

Alright, so recently I've been having a lot of trouble using the new Microsoft.AspNet.Session middleware for ASP.NET vNext (MVC 6). The error I'm getting,

Unable to resolve service for type 'Microsoft.Framework.OptionsModel.ConfigureOptions[Microsoft.AspNet.Session.SessionOptions] while attempting to activate 'Microsoft.AspNet.Session.SessionMiddleware'

occurs on all pages regardless of session use. The DNVM version I'm using is Beta5 x86 and all the packages in the project are Beta5 as well. The project itself is an attempt at porting an ASP.NET MVC 5 project to MVC 6 without much luck. Below are links to resources that may be important:

It seems to be a problem with my configuration but I'm not sure what to do about it... Pls send help Dx

Answer

Run CMD picture Run CMD · Feb 7, 2018

Unable to resolve service for type 'Microsoft.AspNetCore.Session.ISessionStore' while attempting to activate 'Microsoft.AspNetCore.Session.SessionMiddleware'

If you get this error message in ASP.NET Core, you need to configure the session services in Startup.cs:

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc()
        .AddSessionStateTempDataProvider();
    services.AddSession();
}

public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
    app.UseSession();
    app.UseMvcWithDefaultRoute();
}