Guest User

Untitled

a guest
Jan 28th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. public void ProcessRequest (HttpContext context)
  2. {
  3. string Message = "";
  4. try
  5. {
  6. string EmailId = HttpContext.Current.Request["emailid"].ToString();
  7. string Password = HttpContext.Current.Request["Password"].ToString();
  8.  
  9. string User = "";
  10.  
  11. Entities.UserTable user = null;
  12. UserDAL userDAL = new UserDAL();
  13. user = userDAL.UserLogin(EmailId, Password);
  14. if (user != null)
  15. {
  16. int userId = user.Id;
  17.  
  18. string roles = "User";
  19. bool rememberUserName = true;
  20. FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
  21. 1, // Ticket version
  22. user.Id.ToString(),// Username to be associated with this ticket
  23. DateTime.Now, // Date/time ticket was issued
  24. DateTime.Now.AddYears(20), // Date and time the cookie will expire
  25. rememberUserName, // if user has chcked rememebr me then create persistent cookie
  26. roles, // store the user data, in this case roles of the user
  27. FormsAuthentication.FormsCookiePath); // Cookie path specified in the web.config file in <Forms> tag if any.
  28.  
  29. string hashCookies = FormsAuthentication.Encrypt(ticket);
  30. HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hashCookies); // Hashed ticket
  31. cookie.Expires = DateTime.Now.AddYears(20);
  32. HttpContext.Current.Response.Cookies.Add(cookie);
  33.  
  34. Message = "success";
  35. }
  36. else
  37. {
  38. Message = "Please check your Mailid or password.";
  39. }
  40. }
  41. catch(Exception ex)
  42. {
  43. Message = "Please contact Support";
  44. }
  45.  
  46. context.Response.ContentType = "text/plain";
  47. context.Response.Write(Message);
  48. }
Add Comment
Please, Sign In to add comment