Click here to Skip to main content
12,504,560 members (53,113 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# 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:44am
Updated 24-Dec-12 3:12am
Estys12.8K
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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
Top Experts
Last 24hrsThis month


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100