簡體   English   中英

應用程序池回收后 CookieAuthentication cookies 無效

[英]CookieAuthentication cookies are invalid after application pool recycle

我有一個使用配置為使用 CookieAuthentication 的 Microsoft.AspNetCore.Authentication (2.2.0) 的 .net 核心項目。 Cookies 配置為持久並在 7 天后過期。 問題是每當應用程序池被回收時,所有登錄的用戶都會被注銷。

我根本沒有使用會話。 我已經驗證 cookie 仍然存在於 web 瀏覽器中,似乎現有的 cookies 被服務器確定為無效。 我怎樣才能改變這種行為?

這是當前配置:

services
    .AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
    .AddCookie(
        CookieAuthenticationDefaults.AuthenticationScheme,
        options =>
        {
            options.AccessDeniedPath = "/";
            options.LoginPath = "/";
            options.LogoutPath = "/Authentication/Logout";
            options.Events.OnRedirectToLogin = context =>
            {
                context.Response.Redirect("/?returnUrl=" + context.Request.GetEncodedPathAndQuery());

                return Task.CompletedTask;
            });

錯誤是IIS中的應用程序池配置錯誤。 在應用程序池的“高級設置”中,設置“加載用戶配置文件”需要設置為“true”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM