protected void OnLoggingOut(object sender, LoginCancelEventArgs e) { string connectionString = ConfigurationManager.ConnectionStrings["BlogEntities"].ConnectionString; IUserRepository userRepository = new EFUserRepository(connectionString); ISecurityManager securityManager = new FormsSecurityManager(userRepository); securityManager.Logout(); }
protected void Application_AuthenticateRequest(object sender, EventArgs e) { string connectionString = ConfigurationManager.ConnectionStrings["BlogEntities"].ConnectionString; IUserRepository userRepository = new EFUserRepository(connectionString); ISecurityManager securityManager = new FormsSecurityManager(userRepository); securityManager.RefreshPrincipal(); }
public void ProcessRequest(HttpContext context) { string connectionString = ConfigurationManager.ConnectionStrings["BlogEntities"].ConnectionString; IUserRepository userRepository = new EFUserRepository(connectionString); IPictureRepository pictureRepository = new EFPictureRepository(connectionString); int userId = Convert.ToInt32(HttpContext.Current.Request["userId"]); User user = userRepository.GetUser(userId); Picture picture = pictureRepository.GetPicture(user.PictureId); context.Response.ContentType = picture.ImageMimeType; byte[] data = picture.FileData; using (MemoryStream ms = new MemoryStream()) { ms.Write(data, 0, data.Length); ms.WriteTo(HttpContext.Current.Response.OutputStream); } }
protected void lgAuth_OnLoggingIn(object sender, LoginCancelEventArgs e) { string connectionString = ConfigurationManager.ConnectionStrings["BlogEntities"].ConnectionString; IUserRepository userRepository = new EFUserRepository(connectionString); ISecurityManager securityManager = new FormsSecurityManager(userRepository); string userName = lgAuth.UserName; string password = lgAuth.Password; if (securityManager.Login(userName, password) == true) { } else { } }