What is Session in ASP.Net?

Session in ASP.Net
  • Session is a length /period of time that a particular browser instance spends accessing a website.
  • Session Object – The session object is used to persist data across a user session during the user’s visit to a website. It is almost same as the Context object. When we use Response.Redirect, it causes the Context object to go away, so rather the Session object is used in such a scenario. Session object uses more of server memory than a context object. Example code below shows how to use Session object. 

    Syntax :- Session[“sessionname”]=Values;

    If you want to send a data from ‘send.aspx’ page to ‘receive.aspx’ page.
    First, we have to create a session and then assign value to session.


    Redirect the page to the next page


    After redirecting a page we have to receive that session value in string variable.

    str Name=Session[“Name”].ToString();

Leave a Reply

Your email address will not be published. Required fields are marked *

Captcha *