title: Kestrel HTTPS POST results in a 400 bad request status code when in production (ASP.NET Core 2.x)
body: <p>I followed this article <a href="https://docs.microsoft.com/en-us/aspnet/core/security/enforcing-ssl" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/aspnet/core/security/enforcing-ssl</a></p>
  
  <p>Where I setup exactly as the article suggests</p>
  
  <pre><code>// Requires using Microsoft.AspNetCore.Mvc;
  public void ConfigureServices(IServiceCollection services)
  {
      services.Configure&lt;MvcOptions&gt;(options =&gt;
      {
          options.Filters.Add(new RequireHttpsAttribute());
      });
  </code></pre>
  
  <p>and</p>
  
  <pre><code>// Requires using Microsoft.AspNetCore.Rewrite;
  public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  {
      loggerFactory.AddConsole(Configuration.GetSection("Logging"));
      loggerFactory.AddDebug();
  
      var options = new RewriteOptions()
         .AddRedirectToHttps();
  
      app.UseRewriter(options);
  </code></pre>
  
  <p>This seems to work fine when sending a GET request on all browsers. However, when it hits a POST request, I get a 400 status code without much indication of what is causing it -- oddly, this problem does not happen in DEBUG mode.</p>
  
  <p>If I use Edge or IE, this error does not happen. When I use Chrome or POSTMAN, I get the 400 status code.</p>
  
  <p>Oddly, if I use POSTMAN, and I change the POST request to use HTTP, instead of HTTPS I get the 200 (OK) response. So, I am thinking there is some kind of problem with the article above, but I haven't had much luck with the solution.</p>
  
  <p>Anyone have any experience or insight for this problem?</p>