asp.net-core - Wsfederation 错误。令牌过期后,注册用户的注册表单不断弹出
问题描述
我已经按照这个文档WSf在 Asp.net 核心上成功实现了 WSFederation 。当 20 分钟的空闲时间过去后,应用程序通过调用 ADFS 页面重新进行身份验证。但是,应用程序会将注册用户带回注册页面。然后,我将回收应用程序池或重新启动网站以使其再次运行。我该如何解决这个问题?. 控制台显示错误 401
解决方案
on start up
services.AddAuthentication()
.AddWsFederation(WsFederationDefaults.AuthenticationScheme, "Login Using Office Account",
options =>
{
options.MetadataAddress = "https://xxxxxxxxxxxx/FederationMetadata/2007-
06/FederationMetadata.xml";
options.Wtrealm = "https://xxxxxxxxxxxx.org/";
}).AddCookie();
services.ConfigureApplicationCookie(options =>
{
options.LoginPath = "/Identity/Account/LogIn";
}
);
services.ConfigureApplicationCookie(options => options.LogoutPath = "/Home/Index");
and on logout
//delete all cookies first
foreach (var key in HttpContext.Request.Cookies.Keys)
{
HttpContext.Response.Cookies.Delete(key);
}
await _signInManager.SignOutAsync();
_logger.LogInformation("User logged out.");
return SignOut(new AuthenticationProperties { RedirectUri = "/Home/Index" },
CookieAuthenticationDefaults.AuthenticationScheme,
WsFederationDefaults.AuthenticationScheme);
enter code here
The solution I found that works were to increase the application pool idle time from default 20 minutes to any minutes of choice. The user can then work and logout of the application without issues. You can also review the code I have and suggest some improvements if needed
推荐阅读
- c++ - 从 C++ 程序编辑 .exe 文件
- python - 通过单击另一个选项卡中的按钮来更改选项卡的 UI
- delphi - 允许用户从密码字段中复制文本
- c# - WPF 异步加载 UI 元素
- scala - 如何在 spark scala 中检查与其关联的列名和数据是否匹配
- java - Android 本机应用程序 - 如何获取类 android.view.view 中的文本
- go - 嵌套结构的 stringer 函数
- c - 函数指针背后的原因是c语言中的函数名本身?
- python - 使用 PROMPT_COMMAND 时,Python venv 模块无法将虚拟环境名称添加到 PS1?
- python - 与交叉熵损失相比,为什么蒸馏损失不收敛(减少)?