C# ActionContext.RequestContext和HttpContext.Current.Request.RequestContext之间有什么区别

C# ActionContext.RequestContext和HttpContext.Current.Request.RequestContext之间有什么区别,c#,dependency-injection,oauth,asp.net-web-api2,ioc-container,C#,Dependency Injection,Oauth,Asp.net Web Api2,Ioc Container,我正在将标准OAuth实现用于WebApi,利用自定义授权属性来验证用户 几乎与方法2完全相同 我的问题是,索赔中添加的任何信息如下: IList<Claim> claimsCollection = new List<Claim> { new Claim(ClaimTypes.Name, authUser.UserName), new Claim("userID

我正在将标准OAuth实现用于WebApi,利用自定义授权属性来验证用户

几乎与方法2完全相同

我的问题是,索赔中添加的任何信息如下:

            IList<Claim> claimsCollection = new List<Claim>
            {
                new Claim(ClaimTypes.Name, authUser.UserName),
                new Claim("userID", authUser.UserID.ToString()),
                new Claim("dbServer", dbServer),
                new Claim("dbName", dbName)
            };

        ClaimsIdentity oAuthIdentity = new ClaimsIdentity("JWT");
        oAuthIdentity.AddClaims(claimsCollection);

        //add in any permission specific claimns
        if (securityClaimCollection.Count > 0) { oAuthIdentity.AddClaims(securityClaimCollection); };

        var ticket = new AuthenticationTicket(oAuthIdentity, null);
        context.Validated(ticket);
IList claimsCollection=新列表
{
新声明(ClaimTypes.Name、authUser.UserName),
新声明(“userID”,authUser.userID.ToString()),
新索赔(“dbServer”,dbServer),
新索赔(“dbName”,dbName)
};
索赔实体oAuthIdentity=新索赔实体(“JWT”);
oAuthIdentity.AddClaims(索赔集合);
//添加任何特定于权限的声明
如果(securityClaimCollection.Count>0){oAuthIdentity.AddClaims(securityClaimCollection);};
var票证=新的身份验证票证(oAuthIdentity,null);
上下文。已验证(票证);
仅存在于控制器的ActionContext.RequestContext.Principal中。为什么?除了从控制器检索数据外,是否没有其他方法检索声明中的数据?本质上,我是在请求,以便声明中的信息可以被IoC容器访问并用于注入IDBConnection类型