在Microsoft Extensions Package中找不到AddAuthentification方法

问题描述 投票:0回答:1

我试图在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;
                };

            });
authentication asp.net-core-2.1
1个回答
1
投票

这不是Microsoft.Extensions.DependencyInjection的一部分。它只是使用该命名空间,因此不需要显式的额外using语句来显示扩展名。它实际上将存在于Microsoft.AspNetCore.Authentication NuGet包中。

© www.soinside.com 2019 - 2024. All rights reserved.