.NET Core Web api call ERR_CONNECTION_RESET only on IIS - other calls working

Just edit your web.config and set stdoutLogEnabled="true"to true, as well as set the path where the logfile will be written to.

<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <!--
    Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
  -->

  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
    </handlers>
    <aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
  </system.webServer>
</configuration>

But you need to enable at least the console logger, as it basically dumbs the console output to a file.

public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
{
    loggerFactory.AddConsole(Configuration.GetSection("Logging"));
    loggerFactory.AddDebug();
    ...
}

The "Logging" section is configured in appsettings.json, such as

  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information"
    }
  }

I had a similar problem. I am using Entity Framework Core 1.1, which does not allow Lazy Loading. My error was caused from an object graph loop in a many-to-many relationship.

As EFCore 1.1 does not support many-to-many out of the box, my models had looping references. My JSON Serializer became stuck in an infinite loop as it attempted to serialize the data returned from my controller class.

If you have this problem and none of the other solutions work, I suggest changing your Startup.cs file ConfigureServices() method. The line services.AddMvc(); should be changed to this:

services.AddMvc()
    .AddJsonOptions(options => options.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore);

You can log Kestrel with the build-in logging middleware. Make sure logging is enabled in web.config via stdoutLogEnabled like so:

<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false">

And your startup.cs contains the the following code:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    loggerFactory.AddConsole(LogLevel.Trace);
}