private void LoadUser(UserInfo user) { if(user == null) return; lblName.Text = user.FirstName + " " + user.LastName; lblAddress.Text = user.Address.ToString(); lblEmail.Text = user.Email; lblAccount.Text = string.Format("UserId=[{0}], Password=[{1}]", user.UserName, user.Password); rptFavorites.DataSource = user.FavoriteMovies; rptFavorites.DataBind(); lblMessage.Text = @"Load UserInfo from Cookie"; }
private void SaveUser() { Response.Cookies.Clear(); var user = new UserInfo("Peter", "Bromberg", "101 Park Avenue West", "New York", "NY", "10021", "*****@*****.**", "petey", "whodunnit"); // 쿠키 크기를 더 키우면 Browser에서 에러가 발생할 수 있다. 이때에는 Browser의 모든 cookie값을 삭제한 후 재 시도한다. for(var i = 0; i < 300; i++) // user.FavoriteMovies.Add(i.ToString(), "Favorite Movie Number-" + i.ToString()); user.FavoriteMovies.Add("Favorite Movie Number-" + i); CookieTool.SetChuck(USER_COOKIE, user); var size = Request.Cookies[USER_COOKIE].Value.Length; lblMessage.Text = string.Format("Save UserInfo to cookie with compression name=[{0}], size=[{1}] bytes.", USER_COOKIE, size); }
public static UserInfo GetSample(int favoriteMovieCount) { var user = new UserInfo("Peter", "Bromberg", "101 Park Avenue West", "New York", "NY", "10021", "*****@*****.**", "petey", "whodunnit") { HomeAddr = new AddressInfo { Phone = "999-9999", Street = "정릉동", Proeprties = new List<string>() { "home", "addr" } }, OfficeAddr = new AddressInfo { Phone = "555-5555", Street = "논현동", Proeprties = new List<string>() { "office", "addr" } } }; for(int i = 0; i < favoriteMovieCount; i++) { user.FavoriteMovies.Add("Favorite Movie Number-" + i); } return user; }