ASPNETZERO - 验证问题

时间:2017-08-11 16:57:06

标签: jquery model-view-controller

升级到ASPNETZERO V4.X后,我遇到了多种ASPNETZERO / ABP模板的奇怪验证错误。我正在处理多个项目,我正在使用.NET MVC5模板,.NET Core MVC模板和带有BSB管理主题的ABP开源模板。我在所有这些不同的项目中得到了相同的验证消息。这是一个例子。

Chrome console showing validation error

Chrome console showing values sent to app service

Another error example from ABP open source version

有谁知道如何找到此错误的根本原因。如何调试ABP验证代码以查找此错误的根本原因? 此外,有时错误不会出现,应用程序服务调用正常执行。但是,那么你再试一次,一分钟之后又失败了!

1 个答案:

答案 0 :(得分:0)

所以今天,我能够找到记录在内部日志文件中的错误消息。我发现以下错误已记录。

  

Newtonsoft.Json.JsonSerializationException:将值{null}转换为' System.Decimal'时出错。路径'宽度',第1行,位置99. ---> System.InvalidCastException:无法将Null对象转换为值类型。      at System.Convert.ChangeType(Object value,Type conversionType,IFormatProvider provider)      at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader,Object value,CultureInfo culture,JsonContract contract,Type targetType)      ---内部异常堆栈跟踪结束---      at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(JsonReader reader,Object value,CultureInfo culture,JsonContract contract,Type targetType)      at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader,Type objectType,JsonContract contract,JsonProperty member,JsonContainerContract containerContract,JsonProperty containerMember,Object existingValue)      at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty属性,JsonConverter propertyConverter,JsonContainerContract containerContract,JsonProperty containerProperty,JsonReader reader,Object target)      at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject,JsonReader reader,JsonObjectContract contract,JsonProperty member,String id)

这是在我的一个十进制属性(宽度)上报告的,这是可选的,不是必需的。我使用下面的代码将属性更改为接受null。

  

小数?

在更改之后,它解决了我的某个实体的验证错误。我会检查其他项目是否有同样的问题。