user12427270
user12427270

Reputation: 41

AspNetCoreModuleV2 issue .NET Core 3.0

Hoping someone can help out with this issue:

I've deployed my .NET Core 3.0 application on Azure, and even though the it it shows "Publish Succeeded." the application isn't loading (http 500, server error). The "Diagnose and solve problems" tab in Azure point to the module "AspNetCoreModuleV2" as shown in picture Azure - Diagnose and solve problems

I've tried:

Here is my current csproj file:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Folder Include="wwwroot\" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.0.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.6" />
    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.0.1" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.1.0-preview1-final" />
  </ItemGroup>

</Project>

In this is what my web.config file looks like

<?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=".\SportsStore.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" hostingModel="inprocess" />
    </system.webServer>
  </location>
</configuration>
<!--ProjectGuid: 3f1b616a-5c07-4b23-9c86-ec6506dc3fa7-->

By the way, the application runs without any issues in the local machine

Any help that can point me in the right direction is highly appreciated.

Upvotes: 2

Views: 14591

Answers (5)

Steve42
Steve42

Reputation: 219

What worked for me, after spending many hours, I'm using VS 2022. I hope it helps someone else.

In web.config, I changed "inprocess" to "OutOfProcess"

  <aspNetCore processPath="dotnet" arguments=".\myappdemo.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="OutOfProcess" />

Upvotes: 0

c-romeo
c-romeo

Reputation: 408

Edit your csproj

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
    <AspNetCoreModuleName>AspNetCoreModuleV2</AspNetCoreModuleName>
..

in this way during dotnet publish the TransformWebConfig task transforms your web.config as following, which works also in Azure WebApp

<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
      <aspNetCore processPath="dotnet" arguments=".\assembly.dll" hostingModel="OutOfProcess" />
    </system.webServer>
  </location>
</configuration>

In Azure WebApp the HTTP Error 500.31 - ANCM Failed to Find Native Dependencies error it seams to be cause by InProcess hosting model and module AspNetCoreModuleV2

Upvotes: 10

user12427270
user12427270

Reputation: 41

I've tried publishing as "self-contained" and modifying the web.config, however, nothing worked.

After further research I've found out about the "App Service Editor" tool in Azure. Having a look to the output errors I've realised the issue was to do with the database firewall blocking "my" IP. I had added a rule with my IP previously, however, the IP shown in the error message was different to my actual IP, for some reason. Once the I added another rule on the database with this IP, it worked immediately.

Another strange thing is that the error reported by the "Diagnose and solve problems" tool (AspNetCoreModuleV2) had not much to do with the actual issue.

Thanks everyone for taking the time to answer my question.

Upvotes: 2

Emin Mesic
Emin Mesic

Reputation: 1811

You can try change web.config directly on Azure, so when you deploy application go to the web.config and replace AspNetCoreModuleV2 to AspNetCoreModule. Changing web.config directly will restart application poll, just to understand what is problem.

Please see same article, with possible solutions:

AspNetCore 3.0 - HTTP Error 500.0 - ANCM In-Process Handler Load Failure

Upvotes: 0

jazb
jazb

Reputation: 5791

Have a check under the PublishProfiles folder (inside Properties) and ensure you have :

<SelfContained>true</SelfContained>

A self-contained application distributes the runtime with the application.

Upvotes: 1

Related Questions