How to use session in ASP.NET?

Posted by Tripati_tutu under ASP.NET category on | Points: 40 | Views : 3055
To set a session:-
Session("SiteName") = "DotNetFunda";
//Here you directly assigning value
Session("SiteName") = txtGetSiteName.Text;
//Here you will get the value from textbox.

To get the session value:-
txtShowSite.Text = Session("SiteName");

Suppose you want to clear the session variable, then write
Session("SiteName") = null;

If you want to clear all the session variables from your application, then use

In case of ASP.NET application by default the ASP.NET session state is enabled.

Comments or Responses

Login to post response