netCore WebAPI基础2
API传参
在操作方法的参数前面使用Attribute

幂等性

对请求的数据验证
简单验证
1 | using System.ComponentModel.DataAnnotations; |
属性级别验证
1 | //增加验证Title和Description不能相同 |
类级别验证
1 | //创建Attribute |
验证失败返回422状态码
1 | //在program中设置 |

netCore WebAPI基础2
在操作方法的参数前面使用Attribute


1 | using System.ComponentModel.DataAnnotations; |
1 | //增加验证Title和Description不能相同 |
1 | //创建Attribute |
1 | //在program中设置 |

netCore WebAPI基础2