Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 引用类型';认证票';声明其定义见';Microsoft.AspNetCore.Authentication';,但是找不到_C#_.net_Asp.net Identity_Identity_Asp.net Core 2.0 - Fatal编程技术网

C# 引用类型';认证票';声明其定义见';Microsoft.AspNetCore.Authentication';,但是找不到

C# 引用类型';认证票';声明其定义见';Microsoft.AspNetCore.Authentication';,但是找不到,c#,.net,asp.net-identity,identity,asp.net-core-2.0,C#,.net,Asp.net Identity,Identity,Asp.net Core 2.0,我有一个ASP.NET Core 2应用程序,现在我在从Core 1x迁移代码时遇到了一些问题。这里我们有一小段代码。我有这个错误,有人能告诉我这件事有什么变化吗? PS:所有四个错误都是相同的: 对类型“AuthenticationTicket”的引用声明它在中定义 “Microsoft.AspNetCore.Authentication”,但找不到它 private async Task您的引用列表表明您正在混合为ASP.NET Core 1.x设计的包和需要2.x的包。由于在2个ASP.

我有一个ASP.NET Core 2应用程序,现在我在从Core 1x迁移代码时遇到了一些问题。这里我们有一小段代码。我有这个错误,有人能告诉我这件事有什么变化吗? PS:所有四个错误都是相同的:

对类型“AuthenticationTicket”的引用声明它在中定义 “Microsoft.AspNetCore.Authentication”,但找不到它


private async Task

您的引用列表表明您正在混合为ASP.NET Core 1.x设计的包和需要2.x的包。由于在2个ASP.NET核心包之间引入了大量更改,因此为1.x构建的与身份验证相关的包不可能与2.0一起使用


尝试更新软件包以使用ASP.NET Core 2.0兼容版本
AspNet.Security.OAuth.Validation
AspNet.Security.OpenIdConnect.Primitives
AspNet.Security.OpenIdConnect.Server
都已更新,以支持新的身份验证API(注意:不需要引用最后两个包,因为它们是由OpenIddict间接引用的).

我认为我的答案不正确。似乎发生的是Asp.Net Core 2中的
AuthenticationTicket
中删除了
SetResources
SetScopes
方法。我正在努力找到他们现在在哪里,或者找到新的方法。那将是非常棒的,感谢先进!看来整个想法都变了,我在网上找不到任何关于这种方法的参考。我想如果你想在票据上设置索赔,你就在创建票据之前将其设置为与委托人对抗。因为它不是坏的,可能有一些东西。这是一些工作,再次感谢你,请告诉我哪些包是为asp.net核心1x,所以我可以删除它们,我是相当新的asp.net核心,这是非常复杂的。顺便说一句,谢谢你的邀请answer@dayanrr91你可以从我提到的3个包开始。要知道其他包是为1.x还是2.x制作的,你可以在上面键入它们的名称,看看它们是否引用了1.x还是2.x ASP.NET核心包。例如,非常感谢,伙计,我没有注意到我指向的是Core 1x的包。我只是升级了它们,错误就消失了。
[errors in the code][1]
 private async Task<AuthenticationTicket> CreateTicketAsync(OpenIdConnectRequest request, ApplicationUser user, AuthenticationProperties properties = null)
    {
        // Create a new ClaimsPrincipal containing the claims that
        // will be used to create an id_token, a token or a code.
        var principal = await _signInManager.CreateUserPrincipalAsync(user);

        // Create a new authentication ticket holding the user identity.
        var ticket = new AuthenticationTicket(principal, new AuthenticationProperties(), OpenIdConnectServerDefaults.AuthenticationScheme);
        ticket.SetResources(request.GetResources());**// ERROR IN THIS LINE**

        //if (!request.IsRefreshTokenGrantType())
        //{
        // Set the list of scopes granted to the client application.
        // Note: the offline_access scope must be granted
        // to allow OpenIddict to return a refresh token.
        ticket.SetScopes(new[] **// ERROR IN THIS LINE**
        {
                OpenIdConnectConstants.Scopes.OpenId,
                OpenIdConnectConstants.Scopes.Email,
                OpenIdConnectConstants.Scopes.Profile,
                OpenIdConnectConstants.Scopes.OfflineAccess,
                OpenIddictConstants.Scopes.Roles
            }.Intersect(request.GetScopes())); **// ERROR IN THIS LINE**
        //}
}