欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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

上一篇:

下一篇: