我正在尝试使用DataAnnotation创建Range以键入long数字,但它总是抛出异常,我无法修复它。 我认为问题是因为我需要键入一个大数字作为示例07608800000070然后它抛出异常。
我怎么能解决这个问题?
我尝试着
[Range(minimum: 1, maximum: 999999999999999, ErrorMessage = "Type the Parcel ID")] public long parcelID {get;set;}例外
A first chance exception of type 'System.OverflowException' occurred in mscorlib.dllI'm trying to create Range with DataAnnotation to type long number but it always throws an exception and I can't fix it. I think the problem is because I need to type a big number as an example 07608800000070 then it throws the exception.
How could I fix this ?
I'm trying
[Range(minimum: 1, maximum: 999999999999999, ErrorMessage = "Type the Parcel ID")] public long parcelID {get;set;}Exception
A first chance exception of type 'System.OverflowException' occurred in mscorlib.dll最满意答案
我遇到了同样的问题,这是由于jQuery验证中的一个错误 。 他们声称这是固定的,但我认为这又被打破了。 我使用了一种解决方法 (或修复)。
发生的事情是客户端允许的数字大于范围,因为范围JS代码有一个错误,因此当该大数字到达服务器时,服务器端验证由于此错误而中断:
mscorlib.dll中发生了'System.OverflowException'类型的第一次机会异常
确保您的范围的最大值可以适合长(或您使用的任何数据类型),否则即使客户端验证工作,如果它不适合它,您仍将在服务器端获得错误。
I have had the same issue and this is due to a bug in jQuery Validation. They claim it was fixed but I think this is broken again. There is a workaround (or a fix) that I used.
What is happening is that the client side is allowing a number bigger than the range, because the range JS code has a bug, and thus when that big number arrives at the server, the server side validation breaks due to this error:
A first chance exception of type 'System.OverflowException' occurred in mscorlib.dll
Make sure your range's max value can fit into a long (or whatever datatype you use) otherwise even if client side validation was to work, you will still get the error on the server side if it cannot fit into it.
更多推荐
发布评论