'FromHeaderAttribute' 不是属性 class
'FromHeaderAttribute' is not an attribute class
已提取此代码库:
https://github.com/RedRiverSoftware/FromHeaderAttribute
阅读此文后:
https://river.red/binding-to-and-validating-http-headers-with-web-api-2/
我正在尝试改变这个:
public IHttpActionResult EchoHeaders([RedRiver.FromHead.FromHeader]StandardHeaders headers)
对此:
public IHttpActionResult EchoHeaders([FromHeader]StandardHeaders headers)
显然,我需要将它添加到控制器的顶部 class:
using FromHeaderAttribute.Sample.Models;
但是我收到这个错误:
'FromHeaderAttribute' is not an attribute class.
但是,查看代码(我没有更改),“FromHeaderAttribute
”class 显然继承了“ParameterBindingAttribute
”,而“ParameterBindingAttribute
”继承了“System.Attribute
”。
我缺少什么能够定义可用作参数属性而不指定其整个名称空间的属性 - 就像“FromUri
”和“FromBody
”等属性一样?
事实证明,命名 class 'FromHeader' 并尝试将其用作参数属性将不会被识别。我已经尝试使用许多不同的文件组合、class 和命名空间名称,但它不起作用。属性 class 名称必须是 FromHeader 以外的任何名称。
已提取此代码库:
https://github.com/RedRiverSoftware/FromHeaderAttribute
阅读此文后:
https://river.red/binding-to-and-validating-http-headers-with-web-api-2/
我正在尝试改变这个:
public IHttpActionResult EchoHeaders([RedRiver.FromHead.FromHeader]StandardHeaders headers)
对此:
public IHttpActionResult EchoHeaders([FromHeader]StandardHeaders headers)
显然,我需要将它添加到控制器的顶部 class:
using FromHeaderAttribute.Sample.Models;
但是我收到这个错误:
'FromHeaderAttribute' is not an attribute class.
但是,查看代码(我没有更改),“FromHeaderAttribute
”class 显然继承了“ParameterBindingAttribute
”,而“ParameterBindingAttribute
”继承了“System.Attribute
”。
我缺少什么能够定义可用作参数属性而不指定其整个名称空间的属性 - 就像“FromUri
”和“FromBody
”等属性一样?
事实证明,命名 class 'FromHeader' 并尝试将其用作参数属性将不会被识别。我已经尝试使用许多不同的文件组合、class 和命名空间名称,但它不起作用。属性 class 名称必须是 FromHeader 以外的任何名称。