In Visual Studio 2014, ASP.NET vNext, i am trying to implement Session State in MVC 6.I am not getting any Intellisense in Visual Studio to implement it.Please suggest me how to use it.
相关问题
- Can I use MvcJsonOptions configured during Startup
- Singleton with AsyncLocal vs Scope Service
- gRPC client do not dispose Channel
- Unable to resolve service for type 'Microsoft.
- Which encryption algorithm do we use in Asp.net 5
相关文章
- EF Core 'another instance is already being tra
- Re-target .NET Core to net471, net 472
- How to replace Middleware in integration tests pro
- Why CsvHelper not reading from MemoryStream?
- How to define function that returns html in asp.ne
- Bad Request - Invalid Hostname when accessing loca
- Should I use xUnitPublisher or xUnitBuilder after
- How to log ASP.NET Core input JSON serialization e
Just install the package
and then put
in your Startup.cs. As Eilon pointed out, it will be available via
Update 11/2/2014
The ASP.NET team has started building a new session state middleware to enable session state in ASP.NET vNext. You can check out the Session repo, which has both the Session middleware, as well as a sample.
To enable session state in an app, call:
And to read/write from it:
Original answer
Basically same question as How to do server side state management in vNext Web Applications - session state is not yet implemented in ASP.NET vNext.
As others have noted, TempData is not the same thing as Session State, it is merely built on top of it. (And it is also not yet implemented in ASP.NET vNext.)
I've written a blog post outlining the details of How to Implement Sessions in ASP.NET 5, MVC6. Updated for Beta8
It boils down to:
Microsoft.AspNet.Session
nuget package.services.AddSession()
to startup.csservices.AddCaching()
to startup.csapp.UseSession()
to startup.csHttpContext.Session
inside controllersIHttpContextAccessor
to get to the HttpContext outside of controllers