2017-01-30 5 views
0

.net 핵심 웹 API 프로젝트를 진행 중입니다. 저는 두 개의 컨트롤러를 가지고 있으며 같은 구조를 가지고 있습니다. 그러나 그 중 하나는 작동하지만 다른 하나는 404 오류를 제공합니다. 내 코드 조각은 다음과 같습니다net core web api : 컨트롤러 하나가 작동하지만 다른 컨트롤러가 없습니다

 //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

Thanks @Developer. 나는 주말 내내 문제를 해결하려고 노력했다. – tempx

답변

0

GetItemPrice 방법은 private입니다. public이어야합니다.

관련 문제