diff --git a/NewLife.CubeNC/Areas/Admin/Controllers/UserController.cs b/NewLife.CubeNC/Areas/Admin/Controllers/UserController.cs index e0a2d6b0..7b43423f 100644 --- a/NewLife.CubeNC/Areas/Admin/Controllers/UserController.cs +++ b/NewLife.CubeNC/Areas/Admin/Controllers/UserController.cs @@ -27,7 +27,7 @@ namespace NewLife.Cube.Areas.Admin.Controllers; [Description("系统基于角色授权,每个角色对不同的功能模块具备添删改查以及自定义权限等多种权限设定。")] [AdminArea] [Menu(100, true, Icon = "fa-user", HelpUrl = "https://newlifex.com/cube/cube_security")] -public class UserController : EntityController +public class UserController : EntityController { /// 用于防爆破登录。即使内存缓存,也有一定用处,最糟糕就是每分钟重试次数等于集群节点数的倍数 private readonly ICache _cache; diff --git a/NewLife.CubeNC/Common/EntityModelBinder.cs b/NewLife.CubeNC/Common/EntityModelBinder.cs index 6449bf43..69b04c17 100644 --- a/NewLife.CubeNC/Common/EntityModelBinder.cs +++ b/NewLife.CubeNC/Common/EntityModelBinder.cs @@ -31,10 +31,6 @@ protected override Object CreateModel(ModelBindingContext bindingContext) // 如果提交数据里面刚好有名为model的字段,这是Add/Edit接口的入参,则需要清空modelName,否则无法绑定 if (bindingContext.ModelName == "model") bindingContext.ModelName = String.Empty; } - if (!modelType.As()) return base.CreateModel(bindingContext); - - var fact = EntityFactory.CreateFactory(modelType); - if (fact == null) return base.CreateModel(bindingContext); // 尝试从body读取json格式的参数 var ctx = bindingContext.HttpContext; @@ -50,6 +46,10 @@ protected override Object CreateModel(ModelBindingContext bindingContext) // 强行绑定会出错记录在ModelState,在api中返回400错误,mvc不会 bindingContext.ValueProvider = cubeBodyValueProvider; } + if (!modelType.As()) return base.CreateModel(bindingContext); + + var fact = EntityFactory.CreateFactory(modelType); + if (fact == null) return base.CreateModel(bindingContext); var pks = fact.Table.PrimaryKeys; var uk = fact.Unique;