Asp.net core mvc Azure B2C保持在MVC 6.Net Core 2中登录
我在Azure B2C的WebApp中遇到问题。 每次浏览器关闭时,我都必须再次登录。 这不太方便 有什么解决办法吗? 我已经测试了几个(微软)的例子,同样的效果 Startup.csAsp.net core mvc Azure B2C保持在MVC 6.Net Core 2中登录,asp.net-core-mvc,azure-ad-b2c,asp.net-core-2.0,Asp.net Core Mvc,Azure Ad B2c,Asp.net Core 2.0,我在Azure B2C的WebApp中遇到问题。 每次浏览器关闭时,我都必须再次登录。 这不太方便 有什么解决办法吗? 我已经测试了几个(微软)的例子,同样的效果 Startup.cs public void ConfigureServices(IServiceCollection services) { services.AddAuthentication(auth => { auth.Default
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication(auth =>
{
auth.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
auth.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
auth.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
})
.AddAzureAdB2C(opts =>
{
Configuration.GetSection("Authentication:AzureAdB2C").Bind(opts);
})
.AddCookie(opts =>
{
opts.ExpireTimeSpan = TimeSpan.FromDays(14);
}
);
“IsPersistent=true”是一个可能的解决方案,但没有效果
SessionController.cs
[HttpGet]
public IActionResult SignIn()
{
return Challenge(
new AuthenticationProperties { IsPersistent = true, RedirectUri = Url.Action("SignedIn") },
OpenIdConnectDefaults.AuthenticationScheme);
}
我找到了解决问题的办法
OpenIdConnectionOption->UseLifeTime=false(默认值)或者,如果您不想跨会话保存应用程序cookie,并且您正在使用Azure AD B2C自定义策略,则可以启用“让我登录”(KMSI)功能,如下所示: