1

I recently wrote my first ASP .NET Core (3.1) Web App,

Now I'm looking to deploy it to IIS.

Two guides on deploying that I've read mention adding the following code block:

var host = new WebHostBuilder()
  .UseKestrel()
  .UseContentRoot(Directory.GetCurrentDirectory())
  .UseIISIntegration()
  .UseStartup<Startup>()
  .Build();

However, the Program.cs in My App (as generated by MSVS) simply has:

Host.CreateDefaultBuilder(args)
    .ConfigureWebHostDefaults(webBuilder =>
    {
        webBuilder.UseStartup<Startup>();
    });

The Startup.cs file has a

public void Configure(...)

method, but this doesn't contain either .UseKestrel() OR .UseIISIntegration()

I've deployed my App to IIS Server (by creating an Application Pool). I get no response at http://localhost/MyApp

I looked at the Windows Application Log, and the logs in C:\inetpub\logs\LogFiles\W3SVC1, but I'm not seeing anything obvious

Any advice on how to diagnose this is appreciated

5
  • 1
    Please look at the official documentation on hosting ASP.NET Core in IIS. Commented Feb 8, 2020 at 13:54
  • @poke I have read that documentation, but it doesn't refer to the .UseIISIntegration() I see in other installation guides, i.e. stackify.com/how-to-deploy-asp-net-core-to-iis Commented Feb 9, 2020 at 6:07
  • does WebHost.CreateDefaultBuilder(args) call UseIISIntegration in the background? Commented Feb 9, 2020 at 6:10
  • Yes, the default builder takes care of IIS integration for you. Commented Feb 9, 2020 at 15:50
  • 1
    You will need to set the app pool to no managed code as well. Commented Feb 10, 2020 at 11:46

1 Answer 1

1

I know that time has passed but still.

public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>()
                .UseIISIntegration()
                .UseKestrel();
            });

Do not add: .Build();

Sign up to request clarification or add additional context in comments.

Comments

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.