title: dd/MM/yyyy format not working in ASP.NET Core
body: <p>I am struggling to get the right date format in ASP.NET Core 2.1. I have already various solutions for several hours and simply can't get it to work.
  Things I have tried so far:</p>
  
  <ul>
  <li><p>Setting the culture in Startup.cs <code>ConfigureServices</code> class:</p>
  
  <pre><code>// Add localization
  services.AddLocalization(options =&gt; options.ResourcesPath = "Resources");
  
  services.Configure&lt;RequestLocalizationOptions&gt;(
  opts =&gt;
  {
      var supportedCultures = new List&lt;CultureInfo&gt;
      {
  
              new CultureInfo("nl-NL"),
      };
  
      opts.DefaultRequestCulture = new RequestCulture("nl-NL");
      // Formatting numbers, dates, etc.
      opts.SupportedCultures = supportedCultures;
      // UI strings that we have localized.
      opts.SupportedUICultures = supportedCultures;
      opts.DefaultRequestCulture = new RequestCulture(culture: "nl-NL", uiCulture: "nl-NL");
  });
  
  Thread.CurrentThread.CurrentCulture = new CultureInfo("nl-NL");
  Thread.CurrentThread.CurrentUICulture = new CultureInfo("nl-NL");
  </code></pre></li>
  <li><p>Setting the culture in Startup.cs <code>Configure</code> class:</p>
  
  <pre><code>var supportedCultures = new[] { new CultureInfo("nl-NL") };
  app.UseRequestLocalization(new RequestLocalizationOptions
  {
      DefaultRequestCulture = new RequestCulture("nl-NL"),
      SupportedCultures = supportedCultures,
      SupportedUICultures = supportedCultures
  });
  
  Thread.CurrentThread.CurrentCulture = new CultureInfo("nl-NL");
  Thread.CurrentThread.CurrentUICulture = new CultureInfo("nl-NL");
  </code></pre></li>
  <li><p>Data annotation in viewmodel and normal model, the property first was a <code>DateTime</code> property but that also didn't work:</p>
  
  <pre><code>[DisplayName("Datum van machtiging")]
  [Required(ErrorMessage = "Het veld '{0}' is verplicht")]
  [DataType(DataType.Date), DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
  public string Datum_van_machtiging { get; set; }
  </code></pre></li>
  <li><p>The HTML where it is getting called (if that matters):</p>
  
  <pre><code>&lt;div class="form-group"&gt;
      &lt;label asp-for="Datum_van_machtiging" class="control-label"&gt;&lt;/label&gt;
      &lt;input asp-for="Datum_van_machtiging" class="form-control" /&gt;
      &lt;span asp-validation-for="Datum_van_machtiging" class="text-danger"&gt;&lt;/span&gt;
  &lt;/div&gt;
  </code></pre></li>
  <li><p>Set the right globalization for IIS express as I publish it to IIS.
  <a href="https://i.stack.imgur.com/nW14Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nW14Y.png" alt="IIS globalization"></a></p></li>
  <li><p>My program.cs (If that matters because I publish to local IIS.)</p>
  
  <pre><code>public class Program
  {
      public static void Main(string[] args)
      {
         BuildWebHost(args).Run();
      }
  
      public static IWebHost BuildWebHost(string[] args) =&gt;
          WebHost.CreateDefaultBuilder(args)
              .UseUrls(@"http://0.0.0.0:5000")
              .UseIISIntegration()
              .UseEnvironment("Production")
              .UseStartup&lt;Startup&gt;()
              .Build();
  }
  </code></pre></li>
  </ul>
  
  <p>EDIT: I am getting this warning too by the way: <a href="http://prntscr.com/nxu1d6" rel="nofollow noreferrer">http://prntscr.com/nxu1d6</a></p>