I set HostingModel to "Out Of Process" in VS Debug window. But when publish the project to my DEV server. web.config file showing always hostingModel="inprocess"
. If I remove this attribute I can run the application.
Is there any process while publishing we change hostingModel
to OutOfProcess
. I am using ASP.Net Core 3.1 version for WebAPI
For Visual Studio 2019, changing the project file does not solve the problem.
The following line:
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
Should be added inside in the publish profile "YourProfileName".pubxml file lying in the Properties/PublishProfiles/ project directory.
You need to understand the hierarchy of .Net core in order to understand exactly what you need to know.
Where .NetCore read this configuration from:
First:web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--
Configure your application settings in appsettings.json. Learn more at https://go.microsoft.com/fwlink/?LinkId=786380
-->
<system.webServer>
<modules>
<remove name="WebDAVModule" />
</modules>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" hostingModel="InProcess"></aspNetCore>
</system.webServer>
</configuration>
The value hostingModel="InProcess"
will override all other configuration existing in your project.
Second:
publish profile
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<DeleteExistingFiles>True</DeleteExistingFiles>
<ExcludeApp_Data>False</ExcludeApp_Data>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<PublishProvider>FileSystem</PublishProvider>
<PublishUrl>bin\Release</PublishUrl>
<WebPublishMethod>FileSystem</WebPublishMethod>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<EnvironmentName>staging</EnvironmentName>
</PropertyGroup>
</Project>
The relevant node is AspNetCoreHostingModel
Third:
.csproj
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
<TypeScriptCompileBlocked>true</TypeScriptCompileBlocked>
<TypeScriptToolsVersion>Latest</TypeScriptToolsVersion>
<IsPackable>false</IsPackable>
Any value you will have in .csproj
or publish profile
will get overridden by the webconfig
.
Change the properties in VS Debug window, the project's launchsettings.json
file is updated synchronously, and launchsettings.json
is for VS running the project. To configure an app for out-of-process hosting, set the value of the <AspNetCoreHostingModel>
property to OutOfProcess
in the project file (.csproj):
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
</PropertyGroup>
Reference: https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/aspnet-core-module?view=aspnetcore-3.1
You can change your project file. add
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
inside PropertyGroup
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With