Wsfederation错误。在令牌过期后,注册表单会一直为注册用户弹出

问题描述 投票:0回答:1

我根据这个doc WSf在Asp.net核心上成功实现了WSFederation。当20分钟的空闲时间过去时,应用程序通过调用ADFS页面重新进行身份验证。但是,应用程序将注册用户带回注册页面。然后,我将回收应用程序池或重新启动网站以使其再次运行。我该如何解决这个问题?My registration form。控制台显示错误401

asp.net-core ws-federation
1个回答
0
投票
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
© www.soinside.com 2019 - 2024. All rights reserved.