我有两个共享ASP.Net成员资格表的webapps。
一切正常,但我无法在其中一个应用中删除区分大小写,就像我在另一个应用中那样。
在非工作应用
中void Login1_LoggingIn(object sender, LoginCancelEventArgs e)
{
string username = Login1.UserName.Trim();
if (!string.IsNullOrEmpty(username))
{
MembershipUser user = Membership.GetUser(username);
if (user != null)
{
// Only adjust the UserName if the password is correct. This is more secure
// so a hacker can't find valid usernames if we adjust the case of mis-cased
// usernames with incorrect passwords.
string password = Login1.Password.ToUpper();
if (Membership.ValidateUser(user.UserName, password))
{
Login1.UserName = user.UserName;
}
}
}
}
无效。密码以全部大写形式存储。在创建成员资格用户时转换!
因此,如果密码是PASSWORD,输入PASSWORD允许我进行身份验证。但输入密码不行!即使我可以看到正在发送的字符串是PASSWORD(用toUpper()转换)。
我完全失去了这个...在另一个应用程序中,我可以输入更低或更高或混合,我能够进行身份验证。在另一个应用程序中我虽然没有使用登录控件中的文本框..不确定这是否有所作为?
答案 0 :(得分:0)
您只是使用密码验证用户,您没有登录,这是在流程的后期阶段发生的。
验证密码后,请在更新用户名的同一位置使用密码更新Login1的密码文本框。
我似乎记得密码是只读的,所以你需要使用这样的东西:
((TextBox)Login1.FindControl(view source to find the login inputs id)).Text = password;
这应该可以为您提供所需的结果。