Click here to Skip to main content
15,917,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am beginner in the asp.net. i was able to maintain session as follows:

in index page i.e first page
C#
protected void btnLogin_Click(object sender, EventArgs e)
       {
           Session["UserName"] = txtLogin.Text;
           Response.Redirect("~/mainPage.aspx");
       }


in second page

C#
protected void Page_Load(object sender, EventArgs e)
       {
           if ( Session["UserName"] == null)
           {
               Response.Redirect("~/index.aspx");
           }
       }

but i don't make any changes in web.config.. how is that possible and someone please suggest me links for further study. i am getting confused with these things. :)
thanks in advance.. :)
Posted

Hi
The below link may helpful to you.

Exploring Session in ASP.NET[^]



Regards
Dominic
 
Share this answer
 
In ASP.NET Page_Load event is raised before btnLogin_Click event.
When the user click on a button it generate a postback (the page is send back to the web server) and there the events are managed in a standard order.
Here is a MSDN link[^] that gives you an overview about ASP.NET Page Life Cycle.

And here is a starting point link[^] for creating and working with ASP.NET projects.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900