We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,676 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How to control user accesing to several sites without login

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... :)

2
Contributors
1
Reply
42 Minutes
Discussion Span
1 Year Ago
Last Updated
2
Views
lhsunshine
Newbie Poster
18 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

So you want to redirect users after they login to the page they were last on.

This may help:

http://forums.asp.net/t/1384842.aspx/1

CriticalError
Junior Poster in Training
64 posts since Mar 2012
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.2815 seconds using 2.64MB