小编Bre*_*ell的帖子

IDX21323 OpenIdConnectProtocolValidationContext.Nonce 为空,OpenIdConnectProtocolValidatedIdToken.Payload.Nonce 不为空

我正在尝试对内部网的 Azure AD 和 Graph 进行身份验证(基于 Orchard CMS),这在我的本地机器上按预期运行,但是,当访问将是生产站点的站点时(已经在我们的内部 dns 上设置了 ssl ),我有时会收到上述错误,它相对不一致,我部门中的其他人在访问时通常会收到此错误。

我的身份验证控制器如下:

public void LogOn()
    {
        if (!Request.IsAuthenticated)
        {

            // Signal OWIN to send an authorization request to Azure.
            HttpContext.GetOwinContext().Authentication.Challenge(
              new AuthenticationProperties { RedirectUri = "/" },
              OpenIdConnectAuthenticationDefaults.AuthenticationType);
        }
    }

    public void LogOff()
    {
        if (Request.IsAuthenticated)
        {
            ClaimsPrincipal _currentUser = (System.Web.HttpContext.Current.User as ClaimsPrincipal);

            // Get the user's token cache and clear it.
            string userObjectId = _currentUser.Claims.First(x => x.Type.Equals(ClaimTypes.NameIdentifier)).Value;

            SessionTokenCache tokenCache = new SessionTokenCache(userObjectId, HttpContext);
            HttpContext.GetOwinContext().Authentication.SignOut(OpenIdConnectAuthenticationDefaults.AuthenticationType, CookieAuthenticationDefaults.AuthenticationType);
        }

        SDKHelper.SignOutClient();

        HttpContext.GetOwinContext().Authentication.SignOut( …
Run Code Online (Sandbox Code Playgroud)

c# orchardcms azure-active-directory microsoft-graph-api

12
推荐指数
5
解决办法
3万
查看次数

是否可以在动态/ ExpandoObject上创建通用方法

我怀疑这是不可能的,但我还没有看到明确的否定.

我目前的(工作)实施如下:

public static Main(param args[])
{
    dynamic Repository = GetRepository();

    var query = (Repository.QueryUser() as IQueryable<User>)
                .Where(user => user.Name.ToLower().Contains("jack"));
}

public static dynamic GetRepository()
{
    dynamic repo = new System.Dynamic.ExpandoObject();        
    repo.QueryUser = new [] { new User() { Name = "Jack Sparrow"}}.AsQueryable<User>();
    return repo;
}
Run Code Online (Sandbox Code Playgroud)

为了更好地使用Generic方法模拟(常用的)Repository接口,我想实现类似以下内容:

public interface IRepository
{
    IQueryable<T> Query<T>();
}

public static Main(param args[])
{
    IRepository Repository = GetRepository();  // return a dynamic

    var query = Repository.Query<User>() 
                 .Where(user => user.Name.ToLower().Contains("jack"));
}


public static dynamic GetRepository()
{ …
Run Code Online (Sandbox Code Playgroud)

c# generics dynamic

7
推荐指数
1
解决办法
1167
查看次数

如何组合多个 c# Lambda 表达式 (Expression&lt;Func&lt;T, T&gt;&gt;)

我有以下函数,它实际上是 Z.EntityFramework.Plus 批量更新的包装器:

    public static int UpdateBulk<T>(this IQueryable<T> query, Expression<Func<T, T>> updateFactory) where T : IBaseEntity, new()
    {
        Expression<Func<T, T>> modifiedExpression = x => new T() { ModifiedBy = "Test", ModifiedDate = DateTime.Now };
        var combine = Expression.Lambda<Func<T, T>>(
            Expression.AndAlso(
                Expression.Invoke(updateFactory, updateFactory.Parameters),
                Expression.Invoke(modifiedExpression, modifiedExpression.Parameters)
            ),
            updateFactory.Parameters.Concat(modifiedExpression.Parameters)
        );  //This returns an error

        return query.Update(combine);
    }
Run Code Online (Sandbox Code Playgroud)

像这样调用:

        decimal probId = ProbId.ParseDecimal();

        db.Problems
            .Where(e => e.ProbId == probId)
            .UpdateBulk(e => new Problem() {
                CatId = Category.ParseNullableInt(),
                SubCatId = SubCategory.ParseNullableInt(),
                ListId = Problem.ParseNullableInt()
            }); …
Run Code Online (Sandbox Code Playgroud)

c# linq expression entity-framework-plus

5
推荐指数
1
解决办法
4046
查看次数