2017-01-30 39 views
0

私は.netコアWeb APIプロジェクトに取り組んでいます。私は2つのコントローラを持っており、それらは同じ構造を持っています。しかし一方は働いていますが、他方は404エラーを出しています。私のコードスニペットは、次のとおりです。net core web api:1つのコントローラは動作していますが、もう1つはありません

 //mvc routing in the Configure method in the startup class 
     app.UseMvc(routes => 
     { 
      routes.MapRoute(name: "default", template: "api/{controller}/{action}/{id?}"); 
     }); 

を、私のコントローラは、次のとおりです。

[Route("api/user")] 
public class ManagerController : Controller 
{ 
    //this is working 
    [HttpGet("myitems/{id}")] 
    public IActionResult GetItems(String id){...} 
} 

../api/user/myitems/123 is working 


[Route("api/price")] 
public class HistController : Controller 
{ 

    //this is not working !!! 
    [HttpGet("item/{id}")] 
    private IActionResult GetItemPrice(String id) {...} 
} 

../api/price/item/123 is not working! (404 error) 

あなたは解決策を提案してくださいことはできますか?

+1

なぜこのメソッドは「プライベート」ですか?それを 'public IActionResult GetItemPrice'に変更してください。 – Developer

+0

ありがとう@Developer。私は週末全体の問題を解決しようとしていました! – tempx

答えて

0

GetItemPriceの方法は、privateです。それはpublicである必要があります。

関連する問題