c# - 使用 c# 从 ADFS 注销
问题描述
我使用 ADFS 创建了一个 asp.net webform 应用程序。使用模板附带的默认方法登录和注销工作完美。
例如,模板中包含的注销按钮方法
protected void Unnamed_LoggingOut(object sender, LoginCancelEventArgs e)
{
// Redirect to ~/Account/SignOut after signing out.
string callbackUrl = Request.Url.GetLeftPart(UriPartial.Authority) + Response.ApplyAppPathModifier("~/Account/SignOut");
HttpContext.Current.GetOwinContext().Authentication.SignOut(
new AuthenticationProperties { RedirectUri = callbackUrl },
WsFederationAuthenticationDefaults.AuthenticationType,
CookieAuthenticationDefaults.AuthenticationType);
}
我已经设置了一个计时器,当达到零时,我尝试使用上面的代码将用户注销,但它不起作用。没有抛出错误。
任何建议如何在这里执行注销?
解决方案
您是否尝试过没有计时器直接发布的上述代码?它起作用了吗?
另外,尝试实现下面的代码,看看它是否有效。
public void LogOut()
{
var module = FederatedAuthentication.WSFederationAuthenticationModule;
module.SignOut(false);
var request = new SignOutRequestMessage(new Uri(module.Issuer), module.Realm);
Response.Redirect(request.WriteQueryString());
}
推荐阅读
- c++ - 在 constexpr 上下文中使用 std::vector 周围的平面集包装器
- ios - 为什么我的 Firebase 项目云消息传递 iOS 配置部分为空白?
- perl - Perl 剪切字符串的精确部分并存储第一个分隔符
- javascript - React 本机项目不运行 Android
- python - 具有模型拟合的 TensorFlow 错误的 IMDB 数据库的 RNN
- ssl - 从 .NET 5 中的 ServicePointManager.SecurityProtocol 解析密码套件
- php - 获取 PHP DOM-XML 的最后一个孩子的文本值需要很长时间
- android - 如何在没有 otp 代码的情况下登录现有的 firebase 用户?
- javascript - 如何在 ejs(浏览器构建)中使用正则表达式?
- graphql - 无法将 GraphQL 路由器用于 MuleSoft 组件