Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • Installing the .NET 3.0 Runtime Hosting Bundle as suggested here aspNetCore 2.2.0 - AspNetCoreModuleV2 error

  • Changing the modules="AspNetCoreModuleV2" to modules="AspNetCoreModule" on the web.config file, but the file reverts back to its original values once I publish the app.

  • Adding <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel> to the csproj but it didn't make a difference so I've deleted that

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.

like image 502
user12427270 Avatar asked Jul 10 '26 20:07

user12427270


2 Answers

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

like image 171
c-romeo Avatar answered Jul 13 '26 09:07

c-romeo


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.

like image 42
user12427270 Avatar answered Jul 13 '26 11:07

user12427270