Friday, 6 July 2012

How can we protect Pages in asp.net that only Login Page is run when we run any page r when we copy past other page rul then run only Login Page

step 1

put following code in page load
 Session["login"] =null;

step 2

write on login button click
 if (dr.Read())
        {

            Session["login"] = "admin";
            Response.Redirect("Home.aspx");
        }
        else
        {
            lblmsg.Text = "user id and password does not  match";
        }

step 3

write on every page
 if (Session["login"] != "admin")
        {
            Response.Redirect("Login.aspx");
        }


No comments:

Post a Comment