Two other alternatives are:
Option 1.
Open the .csproj file and add the below property to apply the proper hosting model.
<PropertyGroup>
...
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
</PropertyGroup>
In ASP.NET Core apps we don't have web.config so first, we have to publish your application and in the published folder you can see there your web.config the file generated by .NET 5 Core. Now open the config file.like as given below.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\DotNetCoreApp.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />
</system.webServer>
</location>
</configuration>
The In-process hosting model is the default model. So if you want to change it to other i.e. Out-of-process then you just need to change hostingModel="OutOfProcess"
.
Option 2.
In VS2019
- Close your solution
- Delete
applicationhost.config
in folder .vs or delete the whole .vs
folder. The .vs is a hidden folder and is next to your solution file usually.
- Restart your solution again