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
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(); }
This code helps you...
In Startup.cs file
public void ConfigureServices(IServiceCollection services) { .... services.AddSession(options => { options.IdleTimeout = TimeSpan.FromMinutes(30);//We set Time here options.Cookie.HttpOnly = true; options.Cookie.IsEssential = true; }); ... } public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.UseSession(); app.UseMvc(); }
Thanks!!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With