1.11M Members

How to control user accesing to several sites without login

 
0
 

My problem is for postItem.aspx and giveComment.aspx, users cannot access without login.
Can i use the nested-if method? Then how to use it? Thank you...

In Login.aspx.cs

 if (temp == 1)
        {
        string cmdStr2 = "Select Password from Reg where Username= '" + txtUN.Text + "'";
        SqlCommand pass = new SqlCommand(cmdStr2, con);
        string Password = pass.ExecuteScalar().ToString();
        con.Close();

        if (Password == txtPass.Text)
        {
            if("current page"==postItem.aspx){
            Session["New"] = txtUN.Text;
            Response.Redirect("postItem.aspx");
        }
        }

        if(Password == txtPass.Text)
        {
            if("current page"==giveComment.aspx){
            Session["New"] = txtUN.Text;
            Response.Redirect("giveComment.aspx");
        }
        }

In postItem.aspx.cs

 if (Session["New"] != null)
        {
            Label1.Text += Session["New"].ToString();

        }

        else
        {
            Response.Redirect("Login.aspx");

        }

In giveComment.aspx.cs

 if (Session["New"] != null)
        {
            Label1.Text += Session["New"].ToString();

        }

        else
        {
            Response.Redirect("Login.aspx");

        }

**I want to make it likes if users now in postItem.aspx and without login then after he/she login then it will redirect to postItem.aspx.
On the hands, if users now in giveComment.aspx and without login then after he/she login then it will redirect to giveComment.aspx.

Thank you... :)

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: