.NET Core 3.1 WebAPI IISExpress Hangs on Debug

Viewed 1255

Running latest versions of the following (at the time of writing):

Visual Studio 2019 16.4.5
.NET Core SDK 3.1.102 x64

Browsers tested:

  • Google Chrome 80.0.3987.122
  • FireFox 73.0.1

I've recently upgraded several .Net Core 2.1 to 3.1.

After making the required changes to move to 3.1, I went to start testing and noticed that IISExpress would "hang" when opening a new browser window and never load our launch URL.

Checking the output window in Visual Studio, I noticed that the host settings were not respecting my project's launchSettings.json - the defaults of http://localhost:5000/ and http://localhost:5001/ were being used.

I could open a new browser window and navigate to those URLs and they'd load just fine.

Tried deleting my .vs folder from my local TFS repo. Nuked my local copy and repulled it down from TFS. No luck.

Anyone know what changed that might be causing this?

2 Answers

The problem(?) is a new setting default in your project properties:

v

By default, this is set to "In Process". Changing it to "Out of Process" will return your expected behavior. This change was introduced in .NET Core 2.2 to help increase performance by not proxying web requests through a separate web stack.

If you'd like to take advantage of the better performance offered by in process hosting, add this in your program.cs file, following the line after your "UseKestrel()" call on WebHostBuilder -

.ConfigureKestrel((context, options) => {})

Ran across this today as well (net core 2 -> 3.1). You can futz with in/out of process, but that caused issues for me once I deployed and used IIS. The fix for me was as simple as using what a default 3.1 template would give you:

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

host.Run();

I do not yet understand all of the magic behind these extension methods, so this is a bit cargo-culty, but it seems to work and is in line with the standaard setup.

Related