405 method not allowed Web API

前端 未结 21 1583
栀梦
栀梦 2020-11-27 18:33

This error is very common, and I tried all of the solutions and non of them worked. I have disabled WebDAV publishing in control panel and added this to my web config file:<

21条回答
  •  北海茫月
    2020-11-27 18:56

    For my part my POST handler was of this form:

    [HttpPost("{routeParam}")]
    public async Task PostActuality ([FromRoute] int routeParam, [FromBody] PostData data)
    

    I figured out that I had to swap the arguments, that is to say the body data first then the route parameter, as this:

    [HttpPost("{routeParam}")]
    public async Task PostActuality ([FromBody] PostData data, [FromRoute] int routeParam)
    

提交回复
热议问题