0

I've been having a problem using the new Microsoft.AspNet.Session features in ASP.NET MVC 6 (vNext).

The associated error The error occurs when accessing all pages, including those that don't use the session features themselves. I'm using the beta4 version for everything, including all of my packages and my dnvm environment. The project is running on Visual Studio 2015 RC.

Here are some resources that might be important (if there's anything else anybody needs just comment):

I think it's a problem with the dependency injection for the session package (see first two lines of the stack trace) but after that I'm not sure what to do about it.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

1

Are you sure you've correctly registered the appropriate services in ConfigureServices?

public class Startup {
    public void ConfigureServices(IServiceCollection services) {
        services.AddOptions();
        services.AddSession();
    }

    public void Configure(IApplicationBuilder app) {
        app.UseSession();
    }
}

Note: you need to explicitly register the options services as you're using beta4 packages. This issue was fixed recently: https://github.com/aspnet/Session/commit/dab08ba7e90027a3bf1ef69f740427e93a310f09#diff-2990206dea5be4b3850cad8d4759d577R14

Kévin Chalet
  • 39,509
  • 7
  • 121
  • 131
  • Thank you for the answer, but upon adding all three of those (which I didn't have x{ ) I got a new, similar error about caching. Here's my Startup.cs ( http://pastebin.com/5869Gztn ) and the new error ( http://puu.sh/jawt8/44cc8f6191.png ). If you look at the Startup.cs pastebin, you can see where I added services.AddCaching() to try to fix it. - Here's where the weird comes - After adding it, I started getting the exact same error again. It's repeatable, and I don't know why. – TheNationalSarcasmSociety Jul 24 '15 at 00:32