The application completed without reading the entire request body, .net core 2.1.1

后端 未结 10 1390
-上瘾入骨i
-上瘾入骨i 2020-12-14 07:21

I have created a user register controller to register users with repository design pattern. My controller looks like this.

[Route(\"api/[controller]\")]
             


        
10条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-14 07:37

    I had the same error (even with "Content-Type: application/json") but adding "{id}" into the action verb worked for me i.e. changing from

        [HttpPatch]
        [ActionName("Index")]
        [Authorize(Policy = "Model")]
        public async Task Update([FromRoute]int id, int modelId, [FromBody]Device device)
    

    to

        [HttpPatch("{id}")]
        [ActionName("Index")]
        [Authorize(Policy = "Model")]
        public async Task Update([FromRoute]int id, int modelId, [FromBody]Device device)
    

    (asp.net core 2.1)

提交回复
热议问题