PSU on IIS Host not Loading correctly on the first load - Strange Behavior after Upgrading

Product: PowerShell Universal
Version: 3.7.10

Hello everybody

Im having a very strange behavior since Upgrading my IIS Hosted PSU Environment from Version 3.2.8 to 3.7.10

The PSU environment works. But the first load after a restart of the IIS throws the followinf error:

This page isn’t working right now

can’t currently handle this request.

But after i refresh the Page it works. Its also happening on API Calls, the first call always fails but when i rerun it, then it works.

I checked the Logfile and saw the following error when calling PSU on my browser. But like i said, After refreshing hte Page it works, its only on the first load

2023-02-15 08:02:11.063 +01:00 [INF] User profile is available. Using ‘C:\Windows\system32\config\systemprofile\AppData\Local\ASP.NET\DataProtection-Keys’ as key repository and Windows DPAPI to encrypt keys at rest.
2023-02-15 08:02:12.856 +01:00 [INF] Request starting HTTP/2 GET https://myserver/login?returnUrl=/admin/dashboards - -
2023-02-15 08:02:12.860 +01:00 [INF] Application started. Press Ctrl+C to shut down.
2023-02-15 08:02:12.860 +01:00 [INF] Hosting environment: Production
2023-02-15 08:02:12.861 +01:00 [INF] Content root path: C:\Program Files (x86)\Universal
2023-02-15 08:02:12.899 +01:00 [ERR] Connection ID “18230571297501347850”, Request ID “8000000b-0001-fd00-b63f-84710c7967bb”: An unhandled exception was thrown by the application.
System.ArgumentException: Options.ClientId must be provided (Parameter ‘ClientId’)
at Microsoft.AspNetCore.Authentication.OpenIdConnect.OpenIdConnectOptions.Validate()
at Microsoft.AspNetCore.Authentication.RemoteAuthenticationOptions.Validate(String scheme)
at Microsoft.AspNetCore.Authentication.AuthenticationBuilder.<>c__DisplayClass4_02.<AddSchemeHelper>b__1(TOptions o) at Microsoft.Extensions.Options.ValidateOptions1.Validate(String name, TOptions options)
at Microsoft.Extensions.Options.OptionsFactory1.Create(String name) at Microsoft.Extensions.Options.OptionsMonitor1.<>c__DisplayClass10_0.b__0()
at System.Lazy1.ViaFactory(LazyThreadSafetyMode mode) at System.Lazy1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
at System.Lazy1.CreateValue() at System.Lazy1.get_Value()
at Microsoft.Extensions.Options.OptionsCache1.GetOrAdd(String name, Func1 createOptions)
at Microsoft.Extensions.Options.OptionsMonitor1.Get(String name) at Microsoft.AspNetCore.Authentication.AuthenticationHandler1.InitializeAsync(AuthenticationScheme scheme, HttpContext context)
at Microsoft.AspNetCore.Authentication.AuthenticationHandlerProvider.GetHandlerAsync(HttpContext context, String authenticationScheme)
at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Server.IIS.Core.IISHttpContextOfT`1.ProcessRequestAsync()
2023-02-15 08:02:12.973 +01:00 [INF] Request finished HTTP/2 GET https://myserver/login?returnUrl=/admin/dashboards - - - 500 - - 119.3542ms
2023-02-15 08:02:15.143 +01:00 [INF] PowerShell Universal performance counters do not exist.

I also already Tried reinstlling everything from the ground up as i tought it could be some IIS Configuration. But i still get the Problem in this version but not on 3.2.8

I also don’t get why its a OpenID error, I am not using OpenID. For the Authentication i am using a Form

Kind regards

This could be that PSU isn’t quite configured on the first request. Do to how IIS works on demand, it may be that PSU is starting up and then throws this error and subsequent requests hit a running server and it doesn’t happen.

I think we’ll have to look into why this start happening in more recent versions.

1 Like

Yes please. We have to put workarounds to get the server up and running after restarts and releases. Thanks