Setting Up IIS/Kestrel for InProcess or OutOfProcess Hosting in ASP.NET Core
You can switch the hosting model for your ASP.NET Core application to either ‘InProcess’ or ‘OutOfProcess’ by modifying the settings in the .csproj file:
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>disable</Nullable>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
...
</PropertyGroup>
This setting will update the web.config file after you publish your application.
Additionally, you can configure your application in the Program.cs file with the following code snippet:
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseIISIntegration().UseKestrel(kestrelOptions =>
{
kestrelOptions.ConfigureHttpsDefaults(httpsOptions =>
{
httpsOptions.SslProtocols = SslProtocols.Tls12;
});
}).UseIIS();
Please note that if you use the ‘InProcess’ model but configure your application to host under Kestrel or IIS Integration, you will encounter the following exception when you try to start your web application:
One last thing, it is important to be aware that the order of configuring your web application host (Kestrel/IIS Integration/IIS) is significant. The last setting will overwrite the previous one.