로컬로 잘 작동하는 API가 있고 라이브 환경으로 이동할 때 그렇지 않습니다.WebAPI 컨트롤러가 작동하지 않는 경우
주요 POST의 영향을받는 컨트롤러의 반환에 대한 조치 : 테스트 GET 조치와
NotFound
내가 다시 얻을 :
"Message": "No HTTP resource was found that matches the request URI
을 이상하게도, 나는 동일한 테스트 작업으로 함께 testController을 업로드 할 때 주 컨트롤러에서 사용되는 API에서 적절한 응답을받습니다. 웹 설정
public class DeviceController : ApiController
{
[AllowAnonymous]
[HttpGet]
public HttpResponseMessage helloWorld() // This returns: "No HTTP resource was found that matches the request URI 'http://api.mySite.com/api/Device/helloWorld'."
{
return Request.CreateResponse(HttpStatusCode.OK, "HelloWorld!");
}
[AllowAnonymous]
[HttpPost]
public HttpResponseMessage Login([FromBody] LoginObject loginObject) // This returns: "NotFound"
{
...
}
} 여기
됩니다 :
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "API Default",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}
그래서'HTTP에 의해 같은 경로의 선언 권리? – Marusyk
네, 실제로 "HelloWorld!"를 얻습니다. 뒤로. 이것은 매우 이상하게 보입니다 ... 라우팅 문제가되어야합니까? – Ryan
흠 ... 확인해 볼 수 있습니다. 경로 속성'[Route ("api/Device/helloWorld")]' – Marusyk