I have created an ASP.Net Core 2.0 Web Api. It works perfectly in Visual Studio. But when I deploy it to Windows Server 2012 R2, I get the following error when I try to call any of its endpoints:
HTTP Error 502.5 - Process Failure
In Chrome's console, there is no extra info. However, in Edge's console, it says:
HTTP502: BAD GATEWAY - The server, while acting as a gateway or proxy, received an invalid response from the upstream server it accessed in attempting to fulfill the request. GET - http://eball.propworx.co.za/api/values
On the Event Viewer, this error gets logged twice:
Application 'MACHINE/WEBROOT/APPHOST/EBALL' with physical root 'C:\inetpub\wwwroot\eball\' failed to start process with commandline ' ', ErrorCode = '0x80070057 : 0.
I've spents HOURS on this, and read dozens of web pages. From all I've read, I have set the .NET CLR version to "No Managed Code" in the application pool's basic settings. I have also set "Load User Profile" to "True" in the advanced settings. I have also installed the "Microsoft .NET Core 2.0.0 - Windows Server Hosting" package, and have installed all the latest Windows updates. If I run the API directly from the command prompt by executing "dotnet eball.dll" it runs perfectly and I can call the API's endpoints via http://localhost:5000:
This is the Web.config file that Visual Studio generates when it deploys the app (via FTP)
<?xml version="1.0" encoding="utf-8"?><configuration><system.webServer><handlers><add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" /></handlers><aspNetCore processPath="dotnet" arguments=".\eBall.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" /></system.webServer></configuration><!--ProjectGuid: ccf466e4-3193-4fa6-9140-04b89af4c0fc-->
And this is the project's .csproj file:
<Project Sdk="Microsoft.NET.Sdk.Web"><PropertyGroup><TargetFramework>netcoreapp2.0</TargetFramework><UserSecretsId>8c10401b-bfc2-46d0-9799-2cda71ff5cb1</UserSecretsId></PropertyGroup><ItemGroup><Folder Include="Data\" /><Folder Include="Models\" /><Folder Include="Views\Shared\" /><Folder Include="wwwroot\" /><Folder Include="wwwroot\css\" /><Folder Include="wwwroot\images\" /><Folder Include="wwwroot\js\" /></ItemGroup><ItemGroup><PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" /><PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" /></ItemGroup><ItemGroup><DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" /></ItemGroup></Project>