I have created a user register controller to register users with repository design pattern. My controller looks like this.
[Route(\"api/[controller]\")]
The error info of the application completed without reading the entire request body often occurs when the client send a request that doesn't fulfill the sever requirements . In other words , it happens just before entering the action , resulting that you cannot debug it via a breakpoint within the body of action method .
For example , let's say a action method on the server :
[Route("api/[controller]")]
[ApiController]
public class DummyController : ControllerBase
{
[HttpPost]
public DummyDto PostTest([FromBody] DummyDto dto)
{
return dto;
}
}
The DummyDto here is a dummy class to hold information:
public class DummyDto
{
public int Id { get; set; }
}
When clients send a request with payload not well formatted
For example , the following post request , which doesn't have a Content-Type: application/json header :
POST https://localhost:44306/api/test HTTP/1.1
Accept : application/json
{ "id":5 }
will result in a similar error info :
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request starting HTTP/1.1 POST http://localhost:44306/api/test 10
Microsoft.AspNetCore.Hosting.Internal.WebHost:Information: Request finished in 1.9319ms 404
Microsoft.AspNetCore.Server.Kestrel:Information: Connection id "0HLGH8R93RPUO", Request id "0HLGH8R93RPUO:00000002": the application completed without reading the entire request body.
and the response from the server will be 404:
HTTP/1.1 404 Not Found
Server: Kestrel
X-SourceFiles: =?UTF-8?B?RDpccmVwb3J0XDIwMThcOVw5LTFcU08uQXV0aFJlYWRpbmdXaXRob3V0RW50aXRlQm9keVxBcHBcQXBwXGFwaVx0ZXN0?=
X-Powered-By: ASP.NET
Date: Mon, 03 Sep 2018 02:42:53 GMT
Content-Length: 0
As for the question you described , I suggest you should check the following list :
Content-Type: application/json ? make sure you have checked the header code to show what it sends exactly when you send a request to the server .