我有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 Not foud error

日志形式IIS:

********** GET / api / ListServices - 8081 - ********** Mozilla / 5.0(Windows NT 6.3; WOW64)AppleWebKit / 537.36(KHTML,与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,与Gecko一样)Chrome / 52.0.2743.116 Safari / 537.36 - 404 0 0 78