<HttpGet()>
Public Function Search(<FromUri()> ByVal name As Name) As HttpResponseMessage
// get params from complex type
// or check for model validation
name.firstName;
name.lastName;
End Function
Public Class Name
<Required()>
Public firstName As String
<Required()>
Public lastName As String
End Class
/api/abc/search?firstName=jack&lastName=daniels
我正在尝试将复杂类型作为查询参数发送,但即使我使用 fromUri 属性,名称也始终为空。我错过了什么?
编辑:我也使用 System.ComponentModel.DataAnnotations 的 Required() 属性。