Click here to Skip to main content
16,013,440 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
I am developing a website for my project. In that project there are many web pages in the website. In that Some pages requires authentication to visit those pages. First they have to create their account or sign in their account.

In my login page when the user logins then he moves to a page called profile.aspx.

I am making verification on every page. After verification, if user is not logged in then user is redirect to login page. When he logins then after that he is transferred to a page called "Profile.aspx."

But i want user should redirect to that page from where he was forced to move to login page after verification.

This is my problem.

C#
My Login_btn code is :-

protected void Login_btn_Click(object sender, EventArgs e)
        {
            login_mthd();
        }

        private void login_mthd()
        {
            string constr = (@"server = KANHA-PC; database=codeproject; integrated security=true;");
            SqlConnection con = new SqlConnection(constr);
            SqlCommand cmd = new SqlCommand("select * from id_dtl where user_id='" + id_txtbx.Text + "' and passwrd='" + paswrd_txtbx.Text + "'", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            if (ds.Tables[0].Rows.Count > 0)
            {
                Session["user"] = id_txtbx.Text;
                Response.Redirect("profile.aspx");
            }
            else
            {
                invalid_usr_lbl.Visible = true;
            }
        }


But in my application i want him to move directly on the page what he wants to see instead of "profile.aspx".am making verification on every page. After verification if user is redirect to login page. When he logins then after that he is transferred to a page called "Profile.aspx."

But i want user should redirect to that page from where he was forced to move to login page after verification.

This is my problem.

I am not using inbuild login tools of Visual Studio 2008.

How to create this function.

Thanx in advance

Rakesh Sharma
Posted
Updated 25-Jul-12 21:44pm
v2
Comments
StianSandberg 26-Jul-12 3:47am    
You have some serious security issues with your code. Please read this article Beginners guide to a secure way of storing passwords

1 solution

There are a number of bad ideas here: the first one is that you are storing passwords in clear text - bad idea: Password Storage: How to do it.[^]

The second is simpler: Why are you home brewing this? There is a built in mechanism that is considerably more secure which is available to you: Introduction to Membership[^]
It's also a lot easier to use...
 
Share this answer
 
Comments
kanha.460 26-Jul-12 6:07am    
I can't understand those points. These links are not giving full and right information what i needed.

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