Click here to Skip to main content
15,888,111 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello guys please help me on my project ?
my problem is that there are two pages in my project first is login page for authorized user when user click login button he redirect to second page ...on second page logout button after click he redirect to firstpage that is login ...but when i redirect second page in url it direct goes to second page without login ?????? what i can do for that ??? he need to every time go from first page

What I have tried:

session method am trying ..................................
Posted
Updated 21-Oct-16 4:25am

1 solution

You need to create a session when there is a successful login in the first page like-
C#
if({expression to check if login successful})
{
   Session["UserId"]=UserId; //anything that uniquely describes the logged in user
}

Then in the second page, in page_load event you can put a check like-
C#
protected void Page_Load(object sender, EventArgs e)
{
   If(Session["UserId"]==null)
   //redirect to login page
   //Response.Redirect("Login.aspx"); //to your first page
}


Hope, it helps :)
 
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