System.ArgumentException: Options.ClientId must be provided (Parameter 'ClientId')

Anisha 0 Reputation points
2024-11-30T10:41:50.34+00:00

I am trying to host my .NET core project on windows server IIS, have published the files there but having an error.

Category: Microsoft.AspNetCore.Server.IIS.Core.IISHttpServer

EventId: 2

SpanId: 15ef495fc1e97c42

TraceId: 9f6ade836602c22e139ae05a6b6f46d8

ParentId: 0000000000000000

RequestId: 80000192-0000-b300-b63f-84710c7967bb

RequestPath: /

Connection ID "12898309334399713681", Request ID "80000192-0000-b300-b63f-84710c7967bb": An unhandled exception was thrown by the application.

Exception:

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_0`2.<AddSchemeHelper>b__1(TOptions o)

at Microsoft.Extensions.Options.ValidateOptions`1.Validate(String name, TOptions options)

at Microsoft.Extensions.Options.OptionsFactory`1.Create(String name)

at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)

at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)

at System.Lazy`1.CreateValue()

at Microsoft.Extensions.Options.OptionsCache1.GetOrAdd[TArg](String name, Func3 createOptions, TArg factoryArgument)

at Microsoft.Extensions.Options.OptionsMonitor`1.Get(String name)

at Microsoft.AspNetCore.Authentication.AuthenticationHandler`1.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()

Developer technologies | ASP.NET | ASP.NET Core
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 78,161 Reputation points Volunteer Moderator
    2024-12-02T20:46:48.34+00:00

    you appear to be using AddOpenIdConnect(). this requires several config settings including clientid. if you do not want to specify a clientid, remove the openid support from your application.

    https://learn.microsoft.com/en-us/aspnet/core/security/authentication/configure-oidc-web-authentication?view=aspnetcore-9.0

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.