ASP.NET Core 2.0发布到Azure时出现IIS 502.5错误

5
我开始使用asp.net core 2.0,并用VS 2017创建了一个新项目。将其发布到Windows Azure时,出现了IIS 502.5错误。 enter image description here 检查日志流,我发现如下错误: 未处理的异常:System.FormatException: 短开关“-argFile”在开关映射中未定义。 at Microsoft.Extensions.Configuration.CommandLine.CommandLineConfigurationProvider.Load() at Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers) at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build() at Microsoft.AspNetCore.Hosting.WebHostBuilder.BuildCommonServices(AggregateException& hostingStartupErrors) at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build() at RecruitmentStore.Host.Program.BuildWebHost(String[] args) in D:\RecruitmentStore\RecruitmentStore.Host\Program.cs:line 20 at RecruitmentStore.Host.Program.Main(String[] args) in D:\RecruitmentStore\RecruitmentStore.Host\Program.cs:line 17 IIS详细错误 - 502.5 - 错误网关。 以下是我的web.config。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore requestTimeout="00:20:00" 
                processPath="bin\IISSupport\VSIISExeLauncher.exe" 
                arguments="-argFile IISExeLauncherArgs.txt" 
                forwardWindowsAuthToken="false" 
                stdoutLogEnabled="true" 
                stdoutLogFile="\\?\%home%\LogFiles\stdout"/>
    <directoryBrowse enabled="true" />
  </system.webServer>
</configuration>

我在本地的bin文件夹里看到了生成的IISExeLauncherArgs.txt文件,但不知道它在Azure上如何工作。

enter image description here

请问您如何解决这个问题?我已经多次重启应用服务,但没有帮助。


请将输出作为文本而不是文本截图发布。这会让所有人都更容易 :) - David Ebbo
好的,我编辑了我的问题,谢谢。 - khoailang
但是,如果您从VS部署到应用服务,则不应该获得像那样的配置。我非常确定这就是为什么它出现故障的原因。 - David Ebbo
你是如何发布到Azure Web App的?你需要右键单击项目并选择发布,它应该会自动完成。你在这里展示的web.config文件仅用于VS中的本地调试,不应该出现在App Service上。 - David Ebbo
是的,右键点击并发布,在Azure中创建一个新的配置文件。 - khoailang
显示剩余9条评论
2个回答

5

我们发现,问题出在您的项目中有一个web.config,该文件仅用于在Visual Studio本地调试时使用。如果您将其从项目中排除,msbuild将在部署时生成正确的文件,并且它将在Azure上正确运行。


@DavidvanDugteren 是的,在与 Visual Studio 专家交谈后,他的结论是真正的原因可能是 VS 发布问题,这就是为什么他提交了这个 issue - David Ebbo
你知道如何将Pulsing Core 2.0上传到AWS吗? - dragonfly02

4

web.config文件有一个arguments="-argFile IISExeLauncherArgs.txt"属性,在发布时需要将其删除。以下是一个ASP.NET Core 2.0应用程序的示例,可以在发布过程中实现此操作。我已经使用“文件系统”和“Web部署包”选项进行了测试(适用于AWS EB部署)。

https://github.com/clearwaterstream/aspnet-websdk-issue242-workaround


真遗憾这需要安装gulp才能工作。难道你不能在Windows上替换文件中的字符串而不需要Node和Gulp吗? - NickG
有一些使用PowerShell而不使用Gulp的解决方案,可以参考https://github.com/aspnet/websdk/issues/242此外,这个SDK已经修复了这个问题:https://www.microsoft.com/net/download/dotnet-core/sdk-2.1.300-preview1 - Igor K

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接