I am using ASP.NET Core Identity. After signing in with with password like this:
Microsoft.AspNetCore.Identity.SignInResult result = await signInManager.PasswordSignInAsync(appUser, login.Password, isPersistent:false, lockoutOnFailure:false);
I remain signed in. If the browser window is closed, I'm trying to get the cookie to be removed.
This is my startup code:
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<AppIdentityDbContext>(options =>
options.UseMySql(
Configuration["ConnectionStrings:DefaultConnection"], new MySqlServerVersion(new Version(10, 6, 5))));
services.AddIdentity<AppUser, IdentityRole>().AddEntityFrameworkStores<AppIdentityDbContext>()
.AddDefaultTokenProviders();
services.AddControllersWithViews().AddRazorRuntimeCompilation();
services.AddScoped<IPatientsRepository, PatientRepository>();
services.AddScoped<IWebhooksNotificationsRepository, WebhooksNotificationsRepository>();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAuthentication();
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
}
I set the IsPersistent
property for the cookie to false and I expected that it should not persist if the browser window is closed.