2017-01-27 55 views
0

說完拉着這個代碼庫:'FromHeaderAttribute' 不是一個屬性類

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) 

很顯然,我需要把它添加到控制器類的頂部:

using FromHeaderAttribute.Sample.Models; 

但我收到此錯誤:

'FromHeaderAttribute' is not an attribute class. 

然而,看代碼(我沒有改變)'FromHeaderAttribute'類明確地繼承'ParameterBindingAttribute',它繼承'System.Attribute'。

我缺少什麼能夠定義可用作參數屬性而無需指定整個名稱空間的屬性 - 就像'FromUri'和'FromBody'這樣的屬性?

回答

0

原來,命名一個類'FromHeader'並試圖用它作爲參數屬性不會被識別。我已經嘗試過使用文件,類和命名空間名稱的許多不同組合,並且它不起作用。屬性類名稱必須是除了FromHeader之外的任何內容。

相關問題