Guest User

Untitled

a guest
Feb 8th, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. public ActionResult Login()
  2. {
  3. return View();
  4. }
  5. [HttpPost]
  6. public ActionResult Login(Panel model, string Username, string Password)
  7. {
  8. if (ModelState.IsValid)
  9. {
  10. if (model.Username == Username && model.Password == Password)
  11. {
  12. FormsAuthentication.SetAuthCookie(model.Username, false);
  13. return RedirectToAction("Index", "Test");
  14. }
  15. else
  16. {
  17. ModelState.AddModelError("", "Wrong username or password");
  18. }
  19. }
  20. return View();
  21. }
  22.  
  23. [Authorize]
  24. public ActionResult Index()
  25.  
  26. {
  27.  
  28. return View();
  29. }
  30.  
  31. if (model.Username == Username && model.Password == Password)
  32.  
  33. [HttpPost]
  34. public ActionResult Login(Panel model)
  35. {
  36. if (ModelState.IsValid)
  37. {
  38. if (Membership.ValidateUser(model.Username, model.Password))
  39. {
  40. FormsAuthentication.SetAuthCookie(model.Username, false);
  41. return RedirectToAction("Index", "Test");
  42. }
  43. else
  44. {
  45. ModelState.AddModelError("", "Wrong username or password");
  46. }
  47. }
  48. return View();
  49. }
Add Comment
Please, Sign In to add comment