在 Microsoft 扩展包中找不到 AddAuthentification 方法

Can not find AddAuthentification method in Microsoft Extensions Package

我正在尝试在 ASP .NET Core 2.1 项目上使用 Microsoft.Extensions.DependencyInjection 的方法 AddAuthentification,但在尝试解决它时它似乎不存在于程序包中。

相反,我有一个扩展名 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 包之一中。