microsoft / IIS.Administration

REST API for managing IIS
Other
501 stars 140 forks source link

HTTP/1.1 500 Internal Server Error with UTC <> UTC 00 #329

Open PNL-O opened 3 days ago

PNL-O commented 3 days ago

Hi,

I am located in the Pacific the timezone is UTC-10 All our servers are configured on this timezone to be able to easily use the logs. I need to use the IIS administration API to monitor IIS services. If I set the timezone to UTC it works, if it is UTC-10 I get error 500. Is it possible to correct the code to resolve the problem?

Thanks.

Best regards

Patrick

The error in eventviewer : _Log Name: Application Source: Microsoft IIS Administration API Date: 10/17/2024 2:45:28 AM Event ID: 1 Task Category: None Level: Error Keywords: Classic User: N/A Computer: in-mssqls1-ivw.opt.intranet Description: Category: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware EventId: 1 RequestId: 80000027-0001-f900-b63f-84710c7967bb RequestPath: /api/webserver/application-pools

An unhandled exception has occurred while executing the request.

Exception: System.ArgumentOutOfRangeException: The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset') at System.DateTimeOffset.ValidateDate(DateTime dateTime, TimeSpan offset) at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync() at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync() at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.AuthenticateAsync() at Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext context, String scheme) at Microsoft.AspNetCore.Authorization.Policy.PolicyEvaluator.AuthenticateAsync(AuthorizationPolicy policy, HttpContext context) at Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter.OnAuthorizationAsync(AuthorizationFilterContext context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.gAwaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) at Microsoft.IIS.Administration.WebServer.Injector.ProceedNoTransaction(HttpContext context) at Microsoft.IIS.Administration.WebServer.Injector.Invoke(HttpContext context) at Microsoft.IIS.Administration.HeadTransform.Invoke(HttpContext context) at Microsoft.IIS.Administration.Startup.<>c.<b4_0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.IIS.Administration.Security.Authorization.AuthorizationPolicyMiddleware.Invoke(HttpContext context, IAuthorizationService authorizationService) at Microsoft.IIS.Administration.Security.WindowsAuthenticationExtensions.<>c.<b__0_0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.IIS.Administration.Cors.CorsExtensions.<>c.<b0_2>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.IIS.Administration.Cors.CorsExtensions.<>c__DisplayClass0_0.<b0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.IIS.Administration.ErrorHandler.Invoke(HttpContext context) at Microsoft.IIS.Administration.ErrorHandler.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.gAwaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)

Event Xml:

1 2 0 0x80000000000000 733190 Application in-mssqls1-ivw.opt.intranet Category: Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware EventId: 1 RequestId: 80000027-0001-f900-b63f-84710c7967bb RequestPath: /api/webserver/application-pools An unhandled exception has occurred while executing the request. Exception: System.ArgumentOutOfRangeException: The UTC time represented when the offset is applied must be between year 0 and 10,000. (Parameter 'offset') at System.DateTimeOffset.ValidateDate(DateTime dateTime, TimeSpan offset) at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync() at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync() at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.AuthenticateAsync() at Microsoft.AspNetCore.Authentication.AuthenticationService.AuthenticateAsync(HttpContext context, String scheme) at Microsoft.AspNetCore.Authorization.Policy.PolicyEvaluator.AuthenticateAsync(AuthorizationPolicy policy, HttpContext context) at Microsoft.AspNetCore.Mvc.Authorization.AuthorizeFilter.OnAuthorizationAsync(AuthorizationFilterContext context) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeFilterPipelineAsync>g__Awaited|20_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope) at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext) at Microsoft.IIS.Administration.WebServer.Injector.ProceedNoTransaction(HttpContext context) at Microsoft.IIS.Administration.WebServer.Injector.Invoke(HttpContext context) at Microsoft.IIS.Administration.HeadTransform.Invoke(HttpContext context) at Microsoft.IIS.Administration.Startup.<>c.<<Configure>b__4_0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.IIS.Administration.Security.Authorization.AuthorizationPolicyMiddleware.Invoke(HttpContext context, IAuthorizationService authorizationService) at Microsoft.IIS.Administration.Security.WindowsAuthenticationExtensions.<>c.<<UseWindowsAuthentication>b__0_0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.IIS.Administration.Cors.CorsExtensions.<>c.<<UseCrossOrigin>b__0_2>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.IIS.Administration.Cors.CorsExtensions.<>c__DisplayClass0_0.<<UseCrossOrigin>b__0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.IIS.Administration.ErrorHandler.Invoke(HttpContext context) at Microsoft.IIS.Administration.ErrorHandler.Invoke(HttpContext context) at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task) _
PNL-O commented 3 days ago

Hi, In addition to version 2.3.0 of IIS Administration, it works perfectly in UTC-10. It's really weird because I imagine that the developers' systems located in the USA have a UTC other than 00.

Best regards Patrick