0

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();
2
  • I had the same problem a year or two ago! I took the recommendation from this question and I even bookmarked it to come back. There are updates constantly on techniques on how to do it: stackoverflow.com/questions/58530942/…. Is this a similar problem? Commented May 13 at 17:12
  • @BenMatthews yep, answers from that questions are more or less what I did. thanks Commented May 15 at 7:11

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.