Form Authentication Problem

Feb 3 2010 12:59 AM

Every time I am going to Login page not on next page in this case Default.aspx.
I showing u the url in browser


 Before clicking on Button Login

http://localhost:1567/WebSite3/Login.aspx

After clicking on Button Login

http://localhost:1567/WebSite3/Login.aspx?ReturnUrl=%2fWebSite3%2fDefault.aspx

I am Showing a code here  From web. config file

<authentication mode="Forms">
     
      <forms cookieless="UseCookies" loginUrl="Login.aspx" defaultUrl="Default.aspx" timeout="20">
        <credentials passwordFormat="SHA1">
                  </credentials>
       
      </forms>
    </authentication>
    <authorization>
      <deny users="?"/>
    </authorization>



and code of Login.aspc.cs

protected void btnLogin_Click(object sender, EventArgs e)
    {
        //if (FormsAuthentication.Authenticate(RadTextBox1.Text.Trim(), RadTextBox2.Text.Trim()))
        //{
           
            string sHashedPass = FormsAuthentication.HashPasswordForStoringInConfigFile(RadTextBox2.Text.Trim(), "SHA1");
            string sqlStmt = "Select UserName From UserMaster where UserName='"+RadTextBox1.Text.Trim()+"'and Password='"+RadTextBox2.Text.Trim()+"'";
            SqlConnection con = new SqlConnection("Data Source=ISMART-01;Initial Catalog=SMS;Persist Security Info=True;User ID=sa;Password=root");
            SqlCommand cmd = new SqlCommand(sqlStmt,con);
            //con.Open();
            cmd.Connection.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            //SqlDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
            while (dr.Read())
            {
                Session["User"] = RadTextBox1.Text.Trim();
                Response.Redirect("Default.aspx");
            }
            con.Close();
        //}
    }

Answers (2)