Posted by Anuraj on Tuesday, July 7, 2015 Reading time :1 minute
ASP.NET session state enables you to store and retrieve values for a user as the user navigates ASP.NET pages in a Web application. Sessions values can be stored for the duration of the visitor’s session on your site. Most cases, they are stored in server memory. You can configure session to store either in State server or in SQL Server. In ASP.NET MVC, you can create and access session variables using HttpContext.Current.Session. In ASP.NET 5, ASP.NET team implemented a middleware to support session management.
How to use ASP.NET 5 session middleware.
There are three methods that enable you to set session values: SetInt, SetString and Set, which takes a byte array as an argument. And three methods for get session values as well, GetInt, GetString and Get, which returns byte array for the key. If you want to store custom types in session, you can use Get / Set methods, and you need to implement the serialization and de-serialization logic.
Happy Programming :)