code_junkie

Three Layered Web Application

Nov 13th, 2011
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. public static void ForceLogin()
  2. {
  3. HttpCookie cookie = HttpContext.Current.Request.Cookies[cookieName];
  4.  
  5. if (cookie != null)
  6. {
  7. if (Regex.IsMatch(cookie.Value, "^[0-9]+\.[a-f0-9]+$"))
  8. {
  9. using (EibxDataContext db = new EibxDataContext())
  10. {
  11. int count = db.Logins.Count(l => l.Password == cookie.Value);
  12.  
  13. if (count == 1)
  14. {
  15. return;
  16. }
  17. }
  18. }
  19. }
  20.  
  21. HttpContext.Current.Response.Redirect("~/Login.aspx");
  22. }
Add Comment
Please, Sign In to add comment