Tuesday, February 7, 2012

Session



A Session refers to all the request that a single client makes to a server. A session is specific to the user and for each user a new session is created to track all the request from that user. Every user has a separate session and separate session variable is associated with that session. In case of web applications the default time-out value for session variable is 20 minutes, which can be changed as per the requirement.
private void Button1_Click(object sender, System.EventArgs e)
{
    //Drag TextBox1 and TextBox2 onto a web form
    Session["name"]=TextBox1.Text;
    Session["email"]=TextBox2.Text;
    Server.Transfer("anotherwebform.aspx");
}
Destination web form
private void Page_Load(object sender, System.EventArgs e)
{
    Label1.Text=Session["name"].ToString();
    Label2.Text=Session["email"].ToString();
    Session.Remove("name");
    Session.Remove("email");
}
Related posts:


No comments:

Post a Comment