【发布时间】:2015-02-10 22:15:36
【问题描述】:
以下三种检索索赔的方法有什么不同?
在 ApiController 中调用:
((ClaimsIdentity) HttpContext.Current.User.Identity).Claims
((ClaimsIdentity) Thread.CurrentPrincipal.Identity).Claims
((ClaimsIdentity) User.Identity).Claims
前两个属性存储了相同的数据,但最后一个属性存储了上一个会话的数据。
这是在注销方法中完成的:
UserCache.Instance.Clear();
FederatedAuthentication.SessionAuthenticationModule.SignOut();
HttpContext.Current.User = new GenericPrincipal(new GenericIdentity(string.Empty), null);
更新
混合 WebForms、WebApi、MVC 应用程序
大部分应用程序都是使用 WebForms 构建的。
【问题讨论】: