我试图在Microsoft.Extensions.DependencyInjection
项目中使用AddAuthentification
的方法ASP .NET Core 2.1
,虽然它似乎在尝试解决它时包中不存在。
相反,我有一个扩展AddAuthentificationCore
,没有相同的签名。
根据documentation,它应该存在于.NET Core 2.1
。
P.S
我想使用AddAuthentification
像:
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options => {
options.LoginPath = "/login";
options.AccessDeniedPath = "/AccessDenied";
options.Events.OnRedirectToLogin = (context) => {
context.Response.StatusCode = 401;
return Task.CompletedTask;
};
});
这不是Microsoft.Extensions.DependencyInjection
的一部分。它只是使用该命名空间,因此不需要显式的额外using
语句来显示扩展名。它实际上将存在于Microsoft.AspNetCore.Authentication
NuGet包中。