Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do server side state management in vNext Web Applications

Earlier we have Session to manage state in an ASP.NET web applications. I'm trying to create a simple vNext MVC application where I need to do some state management. Now because System.web is gone how can I use Session in MVC 6 applications. Is it still available in Microsoft.AspNet.Mvc or anywhere else or is there some other server side state management available and how to use? Please help..

like image 272
Rahul Chakrabarty Avatar asked Aug 06 '14 13:08

Rahul Chakrabarty


People also ask

What is state management explain server-side state management in detail?

Server Side State Management. It is another way which ASP.NET provides to store the user's specific information or the state of the application on the server machine. It completely makes use of server resources (the server's memory) to store information.

How do you manage state in ASP.NET application?

Application state is stored in a key/value dictionary that is created during each request to a specific URL. You can add your application-specific information to this structure to store it between page requests. Once you add your application-specific information to application state, the server manages it.

What is state management in asp net core?

Session state. Session state is an ASP.NET Core scenario for storage of user data while the user browses a web app. Session state uses a store maintained by the app to persist data across requests from a client. The session data is backed by a cache and considered ephemeral data.

What is session State Management in asp net?

ASP.NET session state lets you associate a server-side string or object dictionary containing state data with a particular HTTP client session. A session is defined as a series of requests issued by the same client within a certain period of time, and is managed by associating a session ID with each unique client.


1 Answers

Update 11/2/2014

The ASP.NET team has started building a new session state middleware to enable session state in ASP.NET 5. 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:

app.UseSession();

And to read/write from it:

var some_value = context.Session.GetInt("some_value").Value;
some_value++;
context.Session.SetInt("some_value", some_value);

Original answer

Session state is not yet implemented in ASP.NET vNext, but it is in the plans. You cannot use System.Web's session state at all because even if the app is running on full .NET, the session state implementation in System.Web is not compatible with ASP.NET vNext.

like image 91
Eilon Avatar answered Oct 21 '22 05:10

Eilon