小编Goh*_*har的帖子

asp.net mvc处理http 400错误

我有一个ASP.NET MVC 4应用程序,我想将所有HTTP 400错误重定向到我的自定义错误页面.虽然HTTP 400错误没有像404错误那样处理,但我正在寻找一个小时来找到解决方案.有许多解决方案显示如何转义400(错误的请求错误),即允许在url中使用特殊字符.但我无法找到一些解决方案来捕获异常.

请帮助我以某种方式捕获所有HTTP错误请求并将它们重定向到我的错误页面.

asp.net-mvc asp.net-mvc-routing http-status-code-400 asp.net-mvc-4

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

如何为多列 OrderBy 表达式创建表达式树

我已经为 EF 通用存储库创建了一个 orderby 表达式,如下 string command = orderByDesc ? "排序依据降序" : "排序依据";

var type = typeof(T);

var property = type.GetProperty(orderby);

var parameter = Expression.Parameter(type, "p");

var propertyAccess = Expression.MakeMemberAccess(parameter, property);

var orderByExpression = Expression.Lambda(propertyAccess, parameter);

var resultExpression = Expression.Call(typeof(Queryable), command, new Type[] { type, property.PropertyType },

                       items.Expression, Expression.Quote(orderByExpression));
items = items.Provider.CreateQuery<T>(resultExpression);
Run Code Online (Sandbox Code Playgroud)

现在我想创建包含 2 列的表达式用于排序,但无法找到有用的内容。

请帮我创建一个包含 2 列的 orderby 表达式。

.net lambda expression expression-trees

0
推荐指数
1
解决办法
1975
查看次数