[英]'IAppBuilder' does not contain a definition for 'UseCookieAuthentication'
[英]Webaplication does not contain a definition for UseCookieAuthentication
我在 asp.net 核心 6 MVC 上收到此錯誤,我正在嘗試創建 oauth 2.0 代碼授權流程,這應該是我的第一步,但我無法通過在互聯網上進行研究來修復此錯誤。
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Oauth2.Data;
using Microsoft.Owin.Security.Cookies;
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/ExternalLogin/Login"),
});
app.UseOAuthBearerAuthentication(new OAuthBearerAuthenticationOptions()
{
AuthenticationType = DefaultAuthenticationTypes.ExternalBearer,
AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Passive,
});
如果您使用的是 .NET 6 則將其添加到 program.cs 文件
builder.Services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options =>
{
options.LoginPath = "/ExternalLogin/Login";
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.