5
votes

I am starting with asp.net core 2.0 Created a new project with VS 2017. Published it to the windows azure. I got the error IIS 502.5 enter image description here

Check the log stream, I see this

Unhandled Exception: System.FormatException: The short switch '-argFile' is not defined in the switch mappings. 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 Detailed Error - 502.5 - Bad Gateway

And here is my 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>

I see the file IISExeLauncherArgs.txt generated inside the bin folder (in my local), but have no idea how it works in Azure.

enter image description here

Can you please tell me how to fix this? I did restarted the app service several times, that doesn't help

2
Please post the output as text and not a screenshot of the text. This makes it easier for everyone :)David Ebbo
okay, I edited my question, thankskhoailang
And this is with an unmodified default Core 2.0 app created by VS? The web.config does not normally have all these extra switches, so there is something unusual about how you deploy it.David Ebbo
yes, this is the default one created by the VS 2017, ASP.net Core SDK 2.0. What is unusual part?khoailang
A default app does not have a web.config at all, and one gets generated during build (should look like this). So probably something strange with the way you created it if you have that in your project.David Ebbo

2 Answers

5
votes

As we found, the problem is that you have as part of your project a web.config that is only meant to be used when debugging locally in Visual Studio. If you exclude it form the project, msbuild will generate the correct one at deployment time, and it will run correctly on Azure.

4
votes

web.config has arguments="-argFile IISExeLauncherArgs.txt" attribute that needs to be removed during publish. Here's a sample ASP.NET Core 2.0 app where this is achieved during publish. I tested this with "File System" and "Web Deploy Package" options (useful for AWS EB deployments)

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