title: The application completed without reading the entire request body, .net core 2.1.1
body: <p>I have created a user register controller to register users with repository design pattern. My controller looks like this.</p>
  
  <pre><code>[Route("api/[controller]")]
      public class AuthController : Controller
      {
          private readonly IAuthRepository _repo;
          public AuthController(IAuthRepository repo)
          {
              _repo = repo;
          }
  
          [AllowAnonymous]
          [HttpPost("register")]
          public async Task&lt;IActionResult&gt; Register([FromBody] UserForRegisterDto userForRegisterDto){
              // validate request
              if(!ModelState.IsValid)
              return BadRequest(ModelState);
  
              userForRegisterDto.Username = userForRegisterDto.Username.ToLower();
  
              if(await _repo.UserExists(userForRegisterDto.Username)) 
              return BadRequest("Username is already taken");
  
              var userToCreate = new User{
                  Username = userForRegisterDto.Username
              };
  
              var createUser = await _repo.Register(userToCreate, userForRegisterDto.Password);
  
              return StatusCode(201);
          }
      }
  </code></pre>
  
  <p>When I send a request using Postman, it gives me the the 404 not found status code, and API reports the request completed without reading the entire body.</p>
  
  <p><a href="https://i.stack.imgur.com/hqW1o.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hqW1o.png" alt="enter image description here"></a></p>
  
  <p>My request in Postman looks like this.
  <a href="https://i.stack.imgur.com/JWzxt.png" rel="noreferrer"><img src="https://i.stack.imgur.com/JWzxt.png" alt="enter image description here"></a></p>
  
  <p>I have used Data Transfer Objects(DTO) to encapsulate data, I removed <code>UserForRegisterDto</code> and tried to use <code>string username</code> and <code>string password</code>, as follows but it did not work.</p>
  
  <pre><code>public async Task&lt;IActionResult&gt; Register([FromBody] string username, string password)
  </code></pre>
  
  <p><code>UserForRegisterDto</code> looks like this.</p>
  
  <pre><code> public class UserForRegisterDto
      {
          [Required]
          public string Username { get; set; }
  
          [Required]
          [StringLength(8, MinimumLength =4, ErrorMessage = "You must specify a password between 4 and 8 characters.")]
          public string Password { get; set; }
      }
  </code></pre>
  
  <p>I have tried many online solutions for this, but so far nothing resolved my problem. Please help me to troubleshoot the issue, Thank you in advance. I'm running this API on Ubuntu 18.04</p>
  
  <p><strong>Edit:</strong> Startup.cs</p>
  
  <pre><code>public class Startup
      {
          public Startup(IConfiguration configuration)
          {
              Configuration = configuration;
          }
  
          public IConfiguration Configuration { get; }
  
          // This method gets called by the runtime. Use this method to add services to the container.
          public void ConfigureServices(IServiceCollection services)
          {
              services.AddDbContext&lt;DataContext&gt;(x =&gt; x.UseSqlite(Configuration.GetConnectionString("DefaultConnection")));
              services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
  
              services.AddCors();
              services.AddScoped&lt;IAuthRepository, AuthRepository&gt;();
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IHostingEnvironment env)
          {
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
              }
              else
              {
                  app.UseHsts();
              }
              app.UseCors(x =&gt; x.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin().AllowCredentials());
              app.UseMvc();
          }
      }
  </code></pre>