Click here to Skip to main content
15,905,612 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ERROR:This webpage has a redirect loop
The webpage at http://localhost:12205/kreu.aspx?ReturnUrl=%2findex.aspx has resulted in too many redirects. Clearing your cookies for this site or allowing third-party cookies may fix the problem. If not, it is possibly a server configuration issue and not a problem with your computer.

I have created a login system like this but when i run it gives the error

protected void btn_login_Click(object sender, EventArgs e)
        {


            string strCon = ConfigurationManager.ConnectionStrings["ConnectionStringusers"].ConnectionString;

        string strSelect = "SELECT COUNT(*) FROM [Users] WHERE UserName = @Username AND Password = @Password";

 

        SqlConnection con = new SqlConnection(strCon);

        SqlCommand cmd = new SqlCommand();

        cmd.Connection = con;

        cmd.CommandType = CommandType.Text;

        cmd.CommandText = strSelect;

        SqlParameter username = new SqlParameter("@Username", SqlDbType.VarChar, 50);
     username.Value = username_id.Value.Trim().ToString();

        cmd.Parameters.Add(username);


        SqlParameter password = new SqlParameter("@Password", SqlDbType.VarChar, 50);

        password.Value = password_id.Value.Trim().ToString();

        cmd.Parameters.Add(password);

        con.Open();

        int result = (Int32)cmd.ExecuteScalar();

        con.Close();

 

        if (result >= 1)

        {

            Response.Redirect("kreu.aspx");

            Session["username"] = username_id.Value;
            
        }

        else

           Response.Write(@"<script language='javascript'>alert('Invalid username or password!') </script>");

 

    } 
     

        }
}
Posted
Updated 24-Dec-12 3:12am
v2
Comments
[no name] 24-Dec-12 9:11am    
please provide the code for
kreu.aspx

i think there must be some redirection being fired from there

1 solution

Change the url to something else to verify the issue is/isn't in your shown code will help know where the issue is.

Like HashamAhmad said, if it doesn't happen when you change the url then you would need to show the kreu.aspx code to verify where the issue is.

Thanks
 
Share this answer
 

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