asp.net core identity 配置cookie

在Startup类的ConfigureServices方法中,在services.AddIdentity之后,添加如下代码:

services.ConfigureApplicationCookie(options =>
{
    options.AccessDeniedPath = "/Identity/Account/AccessDenied";
    options.Cookie.Name = "YourAppCookieName";
    options.Cookie.HttpOnly = true;
    options.ExpireTimeSpan = TimeSpan.FromMinutes(60);
    options.LoginPath = "/Identity/Account/Login";
    // ReturnUrlParameter requires 
    //using Microsoft.AspNetCore.Authentication.Cookies;
    options.ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter;
    options.SlidingExpiration = true;
});

参考:https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity-configuration?view=aspnetcore-3.1
https://www.cnblogs.com/OpenCoder/p/8341843.html

asp.net core 移除x-power和server头:

https://blog.johnwu.cc/article/asp-net-core-response-header.html

原文地址:https://www.cnblogs.com/AlexanderZhao/p/12878758.html