我正在使用Windows Identity Foundation管理我们网站的登录.
当用户登录时,我正在使用他的请求中的一些信息来提出索赔.一切正常,但现在我需要管理这个场景:
所以我的问题是:
我试过这段代码:
public void ExpireClaims(HttpContextBase httpContextBase)
{
var module =
httpContextBase.ApplicationInstance.Modules["WSFederationAuthenticationModule"] as
WSFederationAuthenticationModule;
if (module == null)
{
return;
}
module.SignOut(true);
}
Run Code Online (Sandbox Code Playgroud)
但模块总是空的.
我试过这个:
public void FederatedSignOut(string replyUrl)
{
WSFederationAuthenticationModule.FederatedSignOut(null, new Uri(replyUrl));
}
Run Code Online (Sandbox Code Playgroud)
但是当我这样做时,我得到一个空的引用execption.
非常感谢.
基本上注销只是删除cookie所以:
FormsAuthentication.SignOut
要么
FederatedAuthentication.SessionAuthenticationModule.SignOut
要么
FederatedAuthentication.SessionAuthenticationModule.DeleteSessionTokenCookie
将工作.
或者使用FederatedPassiveSignInStatus(应该在你的工具箱中).将属性设置SignOutAction为FederatedSignOut,控件将清除您的STS会话.