Alo*_*kin 0 c# linq authentication linq-to-sql
如何改进此用户名/密码检查?
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Login(FormCollection collection)
{
var users =
(from p in _dataContext.Users
where p.Name == collection["Username"] && p.Password == collection["Password"]
select p);
if (users.Count() > 0)
{
// Login Succeed
// To get the username I should do something like users.First().Name
// and that's really bad...
return RedirectToAction("Login");
}
else
{
// Login Faild
return View();
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
874 次 |
| 最近记录: |