asp.net core identity 配置cookie
程序员文章站
2023-12-28 15:56:52
...
在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
推荐阅读
-
asp.net core identity 配置cookie
-
ASP.net core 2.0.0 中 asp.net identity 2.0.0 的基本使用(二)—启用用户管理
-
asp.net core identity学习1
-
ASP.NET Core Identity 实战(4)授权过程
-
ASP.NET Core Identity 实战(3)认证过程
-
ASP.NET CORE[练习]-Identity-Assertion
-
Asp.net core Identity的配置
-
asp.net core 读取Appsettings.json 配置文件
-
用例子看ASP.NET Core Identity是什么?
-
ASP.NET Core配置教程之读取配置信息