我正在为一个学校项目开发一个约会网站,我目前正在尝试为它创建一个登录功能.我们不应该使用自动注册和登录功能.
我们与数据库的任何联系都应该通过WCF服务应用程序.我知道如何在不使用WCF的情况下实现它,但我现在需要使用它,我在搜索后无法在Google上找到它.
public bool login(string UserName, string PassWord, bool isActive = true) {
try {
DALDataContext db = new DALDataContext();
var qry = from m in db.tblUsers
where m.userName == UserName && m.password == PassWord && m.isActive == isActive
select m;
if (qry.Count() > 0) {
return true;
} else {
return false;
}
}
catch (Exception) {
return false;
}
}
Run Code Online (Sandbox Code Playgroud)
我就是这样做的,所以如果我在我的Web应用程序中实现它,这应该是这样的:
ServiceReference1.Service1Client obj = new ServiceReference1.Service1Client();
protected void btnLoginUser_Click1(object sender, EventArgs e) {
try {
string UserName = …Run Code Online (Sandbox Code Playgroud)