Validate Session set after login and redirect user back to login page if it is NULL in ASP.Net

Last Reply on Apr 26, 2013 12:26 AM By Mudassar

Posted on Apr 26, 2013 12:24 AM

Hi

I have made a web page in which there is login screen when user login it goes next page

but my problem is if i directly enter the url of that page it open

i want it should not open unless the user log in

 

Posted on Apr 26, 2013 12:26 AM

After Login you must store UserName in Session variable

Session["User"] = txtUserName.Text;

Now all pages put following checking in page load event

if (Session["User"] == null)
{
Response.Redirect("Login.aspx");
}