2014-03-27 28 views
0

嗨我正在使用wep api 2創建此路線。我已經在wep api上尋找動作2

我WebConfigApi

定義

config.MapHttpAttributeRoutes(); 
    // In Globa.asax 
    GlobalConfiguration.Configure(WebApiConfig.Register); 

 [Route("api/pO")] 
     [AcceptVerbs("Getpo")] 
     [HttpGet] 
     public IEnumerable<pOver> Getpo() 
     { 
      ------ 
     } 

當我運行這個使用

../api/pO/Getpo 

我不斷收到錯誤

"<Error><Message>No HTTP resource was found that matches the request URI 'http://localhost:60482/api/pO/Getp0'.</Message><MessageDetail>No action was found on the controller 'prO' that matches the request.</MessageDetail></Error>" 
我的方法裝飾

請讓我知道如何正確裝飾它來運行它。 感謝

回答

0

我想你希望它看起來是這樣的:

[Route("api/pO/Getpo")] 
[HttpGet] 
public IEnumerable<pOver> Getpo() 
{ 
     ------ 
} 

的AcceptVerbs屬性是爲了做類似的東西HTTPGET屬性,你已經把你的行動。您可以使用AcceptVerbs(「GET」)來代替HttpGet屬性。