Thursday, April 16, 2020

How do I set the time zone in a .NET Core 3.1.4 application?

In Startup.cs you have to use .UseMvc before .UseEndpoints like you were still in the 2.0 stuff like so in Configure:

app.UseMvc(m => m.SetTimeZoneInfo(TimeZoneInfo.Utc));
app.UseEndpoints(endpoints =>
{

 
 

Set the EnableEndpointRouting to false upstream in ConfigureServices to keep this from tanking the application outright.

services.AddMvc(options =>
{
   options.Filters.Add(new BubbleUpExceptions());
   options.EnableEndpointRouting = false;

No comments:

Post a Comment