Witam może ktoś z Was bedzie mi wskazać co robie nie tak... Nie mogę się zalogowac pomimo poprawnie wpisywanych danych...Prubowałem 3 innych rozwiazan i to samo...loguje sie w web.config przez
<authentication mode="Windows" />
a oto kod do logowania.... bede wdzieczny za pomoc
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
string userName = Login1.UserName;
string password = Login1.Password;
bool result = UserLogin(userName, password);
if ((result))
{
e.Authenticated = true;
}
else
{
e.Authenticated = false;
}
}
private bool UserLogin(string userName, string password)
{
string conString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
using (System.Data.SqlClient.SqlConnection con = new System.Data.SqlClient.SqlConnection
(conString
)
)
{
SqlCommand com = new SqlCommand("SELECT login FROM uzytkownik WHERE Login = @login AND Haslo = @haslo", con);
// set the username and password parameters
com.Parameters.Add("@login", SqlDbType.NVarChar).Value = userName;
com.Parameters.Add("@haslo", SqlDbType.NVarChar).Value = password;
con.Open();
string result = Convert.ToString(com.ExecuteScalar());
if (string.IsNullOrEmpty(result))
{
return false;
}
else
{
return true;
}
}
}
protected void Login1_LoggedIn(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(Request.QueryString["ReturnUrl"]))
{
//if (Roles.IsUserInRole(Login1.UserName, "Admins"))
// Login1.UserName = Label23.Text;
Session["LoginName"] = Login1.UserName;
Response.Redirect("profil.aspx?userr=" + Login1.UserName);
//Label23.Visible = true;
// else if (Roles.IsUserInRole(Login1.UserName, "Editors"))
// Response.Redirect("mojprofil.aspx");
}
}