gpt4 book ai didi

c# - AspNetCoreModuleV2问题.NET Core 3.0

转载 作者:行者123 更新时间:2023-12-05 08:31:23 26 4
gpt4 key购买 nike

希望有人能帮忙解决这个问题:

我已在 Azure 上部署了 .NET Core 3.0 应用程序,尽管它显示“发布成功”。应用程序未加载(http 500,服务器错误)。Azure 中的“诊断和解决问题”选项卡指向模块“AspNetCoreModuleV2”,如图所示 Azure - Diagnose and solve problems

我已经尝试过:

  • 按照此处的建议安装 .NET 3.0 运行时托管 bundle aspNetCore 2.2.0 - AspNetCoreModuleV2 error

  • 更改 modules="AspNetCoreModuleV2"modules="AspNetCoreModule"在 web.config 文件中,但一旦我发布应用程序,该文件就会恢复为其原始值。

  • 添加<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>csproj但这没有什么区别,所以我删除了它

这是我当前的 csproj文件:

<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>

这就是我的web.config文件看起来像

<?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-->

顺便说一句,应用程序在本地计算机上运行没有任何问题

非常感谢任何可以为我指明正确方向的帮助。

最佳答案

编辑您的 csproj

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

通过这种方式,在 dotnetpublish 期间,TransformWebConfig 任务将您的 web.config 转换如下,这也适用于 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>

在 Azure WebApp 中,HTTP 错误 500.31 - ANCM 无法找到 native 依赖项 错误似乎是由 InProcess 托管模型和模块 AspNetCoreModuleV2 引起的>

关于c# - AspNetCoreModuleV2问题.NET Core 3.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59025796/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com