POST方法在发布后返回404

时间:2016-11-25 12:25:18

标签: c# rest iis asp.net-web-api

我有ASP.NET Core WebApi。在我的控制器中:

[Route("api/[controller]")]
public class ListServicesController : Controller
{
    [HttpGet]
    public List<CodeList> GetLists()
    {
        // something
    }

    [HttpPost]
    public IActionResult Create([FromBody] CodeList codeList)
    {
        if (codeList == null)
        {
            return BadRequest();
        }

        codesList.Add(codeList);
        return CreatedAtRoute("GetListByName", new { listname = codeList.Name}, codeList);
    }

}

当我从Visual Studio启动它并从POSTMAN发送请求时,每个方法都有效(GET,PUT,POST,DELETE)。我在IIS上发布后,只有GET方法正常工作。在POST时我得到 404没有错误

IIS的日志:

  

********** GET / api / ListServices - 8081 - ********** Mozilla / 5.0 +(Windows + NT + 6.3; + WOW64)+ AppleWebKit / 537.36 + (KHTML,+ like + Gecko)+ Chrome / 52.0.2743.116 + Safari / 537.36 - 200 0 0 6358

     

********** POST / api / ListServices - 8081 - ********** Mozilla / 5.0 +(Windows + NT + 6.3; + WOW64)+ AppleWebKit / 537.36 + (KHTML,+等+壁虎)+镀铬/ 52.0.2743.116 + Safari浏览器/ 537.36    - 404 0 0 78

0 个答案:

没有答案