错误:此网页有重定向循环 [英] Error: This webpage has a redirect loop

查看:99
本文介绍了错误:此网页有重定向循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

错误:此网页有一个重定向循环

http:// localhost:12205 / kreu.aspx的网页?ReturnUrl =%2findex.aspx导致重定向过多。清除此站点的cookie或允许第三方cookie可以解决问题。如果没有,它可能是服务器配置问题,而不是您的计算机的问题。



我已经创建了这样的登录系统,但是当我运行它时会出现错误



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>");

 

    } 
     

        }
}

推荐答案

将网址更改为其他内容以验证问题是否在您显示的代码中将有助于了解问题所在。



像HashamAhmad所说,如果你改变网址时没有发生,那么你需要显示kreu.aspx代码来验证问题所在。



谢谢
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


这篇关于错误:此网页有重定向循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆