Click here to Skip to main content
Sign Up to vote bad
good
See more: C#4.0
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 24 Dec '12 - 2:44
Edited 24 Dec '12 - 3:12
Estys10.8K

Comments
HashamAhmad - 24 Dec '12 - 9:11
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
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 393
1 OriginalGriff 335
2 Arun Vasu 315
3 Maciej Los 238
4 Aarti Meswania 180
0 Sergey Alexandrovich Kryukov 9,680
1 OriginalGriff 7,539
2 CPallini 4,018
3 Rohan Leuva 3,362
4 Maciej Los 2,951


Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 24 Dec 2012
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid