You must Sign In to post a response.
  • Category: ASP.NET

    How to maintain session in asp.net using c#

    how to maintain session in entire application in asp.net using c#

    when i am requesting for new form


    h1.Text = dr.GetString(0) + "<br>";
    h1.NavigateUrl = "Default.aspx?topic_id=" + dr.GetString(1);


    and after clicking i lost my session value from the label which is on the master page..

    how to i maintain session in entire application after login ..so that while submiting new for no need to login again ..
  • #586812
    on login click you can store the session like this


    Session["LoginName"] = txtLoginName.Text;


    and on another page you can check the session like this


    if(Session["LoginName"] != null)
    {
    lblLoginName.Text = Session["LoginName"].ToString()
    //your code
    }
    else
    {
    Response.Redirect("LoginPage.aspx");
    }


    hope this will help you

  • #586827
    Thanks jignesh :)
    Ajay Kumar

  • #586863
    Hi,

    Session["string"]=Label.Text;
    //This is how you set a Session Variable in the code behind.

    If you need to maintian Session through out the application. You need to Set it in the Global.asax file. it where all the Application and Session Level events are handled.

    Thanks and Regards
    Avinash Mohan M.R
    http://amicably.ning.com


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.