How to force sending some field in my model ?
I have a following field:
[DataContract(IsRequired=true)]
double x;
However, when I don't define in xml
request field x
it assigns x=0
. I would like to get effect Bad Request
. How to achieve it ?
you can use [Range] attribute someting like this
[DataContract]
public class Test
{
[DataMember]
[Range(1, 10)]
public int Name{ get; set; }
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.