diff --git a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Timing/AbpTimeZoneMiddleware.cs b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Timing/AbpTimeZoneMiddleware.cs index df70441a31..a126595a16 100644 --- a/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Timing/AbpTimeZoneMiddleware.cs +++ b/framework/src/Volo.Abp.AspNetCore/Microsoft/AspNetCore/Timing/AbpTimeZoneMiddleware.cs @@ -21,21 +21,19 @@ public class AbpTimeZoneMiddleware : AbpMiddlewareBase, ITransientDependency return; } - string? timezone = null; - - if (!context.RequestServices.GetRequiredService().IsAuthenticated) - { - timezone = await GetTimezoneFromRequestAsync(context); - } + // Try to get the timezone from the setting system first + var settingProvider = context.RequestServices.GetRequiredService(); + var timezone = await settingProvider.GetOrNullAsync(TimingSettingNames.TimeZone); if (timezone.IsNullOrWhiteSpace()) { - var settingProvider = context.RequestServices.GetRequiredService(); - timezone = await settingProvider.GetOrNullAsync(TimingSettingNames.TimeZone); + // Try to get the timezone from the HTTP request if the setting is not available + timezone = await GetTimezoneFromRequestAsync(context); } if (timezone.IsNullOrWhiteSpace()) { + // Try to get the timezone from the current running server if the setting and request are not available timezone = context.RequestServices.GetRequiredService().GetCurrentIanaTimezoneName(); }