protected void setCacheDataBtn_Click(object sender, EventArgs e) { if (ObjectCacheQueue.Instance.ContainsKey(CookieName)) { ObjectCacheQueue.Instance.Remove(CookieName); } HttpCookie cookie = new HttpCookie(CookieName); cookie.Expires = DateTime.MinValue; CookieCacheDependency dependency = new CookieCacheDependency(cookie); ObjectCacheQueue.Instance.Add(CookieName, DateTime.Now, dependency); ShowCacheData(); }
private static IPrincipal SetPrincipal(string userID, ITicket ticket) { IPrincipal principal = GetPrincipalInSession(userID); if (principal == null) { LogOnIdentity loi = new LogOnIdentity(userID); string identityID = string.Empty; if (PassportClientSettings.GetConfig().IdentityWithoutDomainName) { identityID = loi.LogOnNameWithoutDomain; } else { identityID = loi.LogOnName; } principal = PrincipalSettings.GetConfig().GetPrincipalBuilder().CreatePrincipal(identityID, ticket); HttpCookie cookie = new HttpCookie(Common.GetPrincipalSessionKey()); cookie.Expires = DateTime.MinValue; CookieCacheDependency cookieDependency = new CookieCacheDependency(cookie); SlidingTimeDependency slidingDependency = new SlidingTimeDependency(Common.GetSessionTimeOut()); PrincipalCache.Instance.Add( Common.GetPrincipalSessionKey(), principal, new MixedDependency(cookieDependency, slidingDependency)); } PrincipaContextAccessor.SetPrincipal(principal); return(principal); }