ASP.NET Session State Overview – Easy Guide to Session State

 

Introduction 


In this Article We will discuss about what are the different ways we should use session in ASP.NET Application and what are the pros and cons of using ASP.NET Session State technique. Before Knowing about the session state I recommend you to read State Management Techniques which helps to ASP.NET Developers develop the applications easily and gives some basic idea about ASP.NET

Here We Begin ,

Definition of  Session State


ASP.NET allows to save values using session state. In Session State the  storage technique that is allow access from all pages requested by a one Web browser session. So It wil access session state to store user-specific information.

Detailed Definition of ASP.NET Session State


Session state is same as to application state, except that it is scoped to the current browser session. If different users are using the application, each user session has a different session state.If a user leaves the single application and then returns later after the session time out the particular peroid, session state information is lost and a new session is created . State is  stored in the Session key/value dictionary.

Trending Now : Facebook Login in ASP.NET Core

Reading and writing session data


Session object is used to store session state. This is an instance of HttpSessionState class and represents a key-value dictionary collection.

Write data to session state

Session[“lastseen”]=DateTime.Now;

Read session state

If(Session[“lastseen”] != null)

{

DateTime lastseen=(DateTime)(Session[“lastseen”]);

}

Advantage of ASP.NET Session State :


  • Similar to using view state and easy to implement
  • Data accessing is very fast and stores session data in memory
  • Multi process configuration

Disadvantage of ASP.NET Session State :


  • It is not suitable for working with large amount of data
  • Application domain recycles all session state will be lost
  • With the use of session state it will affect the performance memory

Conclusion :


I hope this article would have helped you in understanding Session State. For a complete list of support and detailed resources on each of the ASP.NET Concepts described here. It gives you a platform to learn ASP.NET .