Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception: In process hosting is not supported for AspNetCoreModule. Change the AspNetCoreModule to atleast AspNetCoreModuleV2

I am trying to publish asp.net core 2.1 application to azure app service through visual studio and getting following exception. How to resolve this?

C:\Program Files\dotnet\sdk\2.2.108\Sdks\Microsoft.NET.Sdk.Publish\build\netstandard1.0\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(49,5): 
Error MSB4018: The "TransformWebConfig" task failed unexpectedly.
System.Exception: In process hosting is not supported for AspNetCoreModule. Change the AspNetCoreModule to atleast AspNetCoreModuleV2.
   at Microsoft.NET.Sdk.Publish.Tasks.WebConfigTransform.TransformAspNetCore(XElement aspNetCoreElement, String appName, Boolean configureForAzure, Boolean useAppHost, String extension, String aspNetCoreModuleName, String aspNetCoreHostingModel)
   at Microsoft.NET.Sdk.Publish.Tasks.WebConfigTransform.Transform(XDocument webConfig, String appName, Boolean configureForAzure, Boolean useAppHost, String extension, String aspNetCoreModuleName, String aspNetCoreHostingModel, String environmentName)
   at Microsoft.NET.Sdk.Publish.Tasks.TransformWebConfig.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
   at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()

Solution:

Removing <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> from .csproj resolved my issue.

like image 814
Mahbubur Rahman Avatar asked Oct 24 '19 07:10

Mahbubur Rahman


People also ask

Is it possible to host aspnetcoremodule in process?

visual studio - Exception: In process hosting is not supported for AspNetCoreModule. Change the AspNetCoreModule to atleast AspNetCoreModuleV2 - Stack Overflow Exception: In process hosting is not supported for AspNetCoreModule. Change the AspNetCoreModule to atleast AspNetCoreModuleV2 Bookmark this question.

Is the in-process hosting model supported in ASP NET Core?

The in-process hosting model isn't supported for ASP.NET Core apps that target the .NET Framework. The value of <AspNetCoreHostingModel> is case insensitive, so inprocess and outofprocess are valid values.

What is ASP core module in IIS?

ASP.NET Core Module. The ASP.NET Core Module is a native IIS module that plugs into the IIS pipeline to either: Host an ASP.NET Core app inside of the IIS worker process (w3wp.exe), called the in-process hosting model. Forward web requests to a backend ASP.NET Core app running the Kestrel server, called the out-of-process hosting model.

Is it possible to install aspnetcoremodulev2 in System32?

That V2 module is the 5.0. The installer for 5.0 installs the AspNetCoreModuleV2 and that installer does not give you an install options to place it in system32 like the other modules. I'm glad that he said that Change AspNetCoreModuleV2 to AspNetCoreModule inside web.config is not recommended and is just a workaround.


2 Answers

Add this line to your web.config:

<handlers>
  <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>

Or add this property in .csproj file.

<AspNetCoreModuleName>AspNetCoreModuleV2</AspNetCoreModuleName>

Update:

Removing <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> from .csproj resolve my issue.

like image 89
Joey Cai Avatar answered Oct 22 '22 08:10

Joey Cai


To get rid of this error, I disabled the web config transform by setting the IsTransformWebConfigDisabled property to true in my csproj file. A web.config file is useless when using Kestrel on macOS anyway, not sure why the build system tries to transform a non-existent web.config file on macOS in the first place.

<PropertyGroup>
  <IsTransformWebConfigDisabled>true</IsTransformWebConfigDisabled>
</PropertyGroup>
like image 3
0xced Avatar answered Oct 22 '22 06:10

0xced