Guest User

Untitled

a guest
Aug 27th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. public ActionResult Index(Login userLogin)
  2. {
  3. if (ModelState.IsValid)
  4. {
  5. Login Login = loginBusinessLayer.GetUserLogin(userLogin.UserId, userLogin.UserName);
  6. if (Login.UserPassword == userLogin.UserPassword)
  7. {
  8. Session["UserLogin"] = Login;
  9. User user = userBusinessLayer.GetUser(Login.UserId);
  10. Role role = roleBusinessLayer.Roles.Single(rle => rle.RoleId == user.RoleId);
  11. Session["Role"] = role;
  12.  
  13. HttpCookie cookie = new HttpCookie("UserLogin");
  14. cookie["LoginId"] = Convert.ToString(Login.UserId);
  15. cookie["RoleId"] = Convert.ToString(role.RoleId);
  16. Response.Cookies.Add(cookie);
  17. return RedirectToAction("Success", "Login");
  18. }
  19. else
  20. {
  21. return View();
  22. }
  23. }
  24. return View();
  25. }
  26.  
  27. cookie.Expires = DateTime.Now.AddDays(-1);
Add Comment
Please, Sign In to add comment