I'd like to call one UseIISIntegration method on IWebHostBuilder only if certain configuration value is set. My project is on .NET 8 now.
I recognize that's not the most common problem.
Problem is, only way I can get to IConfiguration is when host is built - which is a step too late.
ConfigureAppConfiguration has access to config, but it doesn't have access to IWebHostBuilder.
Is there anything I'm missing? Here's an example of what I need:
var hostBuilder = WebHost
.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
hostingContext.HostingEnvironment.
})
.UseKestrel()
.UseStartup<Startup>();
if (configuration.GetValue<bool?>("appSettings:UseWindowsAuthentication") == true)
{
hostBuilder.UseIISIntegration();
}
var host = hostBuilder.Build();
await host.RunAsync();