Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [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();
- }
- }
- var user = _dataContext.Users.SingleOrDefault(p =>
- p.Name == collection["Username"]
- && p.Password == collection["Password"]);
- if(user != null)
- {
- // Go on...
- return RedirectToAction("Login");
- }
- else
- {
- // Login Faild
- return View();
Add Comment
Please, Sign In to add comment