第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

ASP.NET Core Identity 不會(huì)重定向到正確的登錄頁面

ASP.NET Core Identity 不會(huì)重定向到正確的登錄頁面

C#
慕勒3428872 2022-12-31 10:47:01
以這種方式配置它不起作用。    services        .AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)        .AddCookie(options =>        {            options.ExpireTimeSpan = TimeSpan.FromMinutes(5);            options.LoginPath = $"/logon";            options.LogoutPath = $"/logoff";            options.AccessDeniedPath = $"/accessdenied";            options.SlidingExpiration = true;        })以這種方式配置它正在工作:    services.ConfigureApplicationCookie(options =>    {        options.Cookie.Name = "Caldr.Auth";        options.LoginPath = $"/logon";        options.LogoutPath = $"/logoff";        options.AccessDeniedPath = $"/accessdenied";    });    services        .AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)我希望兩者都有相同的行為。顯然不是。錯(cuò)誤或我沒有得到如何配置它?:-)有什么想法嗎。
查看完整描述

1 回答

?
守著一只汪

TA貢獻(xiàn)1872條經(jīng)驗(yàn) 獲得超4個(gè)贊

在發(fā)布我的問題時(shí),我也配置/添加了身份框架。因此,可能是多種因素共同作用導(dǎo)致它無法正常工作。


工作解決方案:


配置:


var authenticationBuilder = services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)

    .AddCookie(options =>

    {

        options.LoginPath = $"/logon";

        options.LogoutPath = $"/logoff";

        options.AccessDeniedPath = $"/accessdenied";

    });

ConfigureSocialLogins(authenticationBuilder);

實(shí)際登錄(即寫入 cookie 是通過完成的)


private async Task SignInUser(AppUser appUser)

        {

            var claims = new List<Claim>

            {

                new Claim(ClaimTypes.NameIdentifier, appUser.Email),

                new Claim(ClaimTypes.Name, appUser.Displayname ?? appUser.Email),

                new Claim(ClaimTypes.Email, appUser.Email),

            };

            var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);

            var claimsPrincipal = new ClaimsPrincipal(claimsIdentity);


            await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, claimsPrincipal, new AuthenticationProperties());

        }

記下 CookieAuthenticationDefaults.AuthenticationScheme 的所有用法。


查看完整回答
反對(duì) 回復(fù) 2022-12-31
  • 1 回答
  • 0 關(guān)注
  • 131 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)