从使用哈希的网站数据库的用户登录winforms应用程序
本文关键字:用户 登录 winforms 应用程序 数据库 网站 哈希 | 更新日期: 2023-09-27 18:02:33
我在Visual studio2012中有一个解决方案,一个网站和一个winform应用程序。在网站上,我使用asp.net配置进行登录和注册。在网站的认证是完美的工作。它使用用户名并存储密码(哈希值)。我需要登录在winform应用程序与网站的用户。我试过了,但似乎行不通。
SqlConnection con = new SqlConnection(@"Data Source=.;Initial Catalog=Basketball;Integrated Security=True;User ID=userpol;Password=poluser");
SqlDataAdapter sda = new SqlDataAdapter("Select count(*) From aspnet_Membership where UserId='" + textBoxUser.Text + "' and Password ='" + textBoxPass.Text + "'", con);
DataTable dt = new DataTable();
sda.Fill(dt);
if (dt.Rows[0][0].ToString() == "1")
{
this.Hide();
GameChoose gc = new GameChoose();
gc.Show();
}
else
{
MessageBox.Show("please check your username and password");
}
如何使用ASP的成员资格提供程序。. NET在WINFORM应用程序?我只想认证用户,通过。
最后我使用了Web Service
public bool Validate(string username, string password)
{
return Membership.ValidateUser(username, password);
}
和登录表单:
bool result = basketballWcf.Validate(textBoxUser.Text, textBoxPass.Text);
if (result)
{
this.Hide();
GameChoose gc = new GameChoose();
gc.Show();
}
else
{
MessageBox.Show("check please USERNAME or PASSWORD");
textBoxPass.Text = "";
}