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

I now have a complete loss ...

I have a .NET Core web application and everything works in the workplace. There are several WebAPI endpoints, again everything works as intended with GETand returns JSON correctly.

When I publish to IIS, one and only one of these endpoints stop working and throw (failed) net:ERR_CONNECTION_RESET(in Chrome, other browsers throw their own errors).

What is so special is that all other Web API calls work, all in the same environment, and invoke the same database using the same context and EF data service.

I can't figure out how to get detailed logs from Kestrel in some other logging services, either Windows Event Viewer, text file, email, or something else! I have not used most of the middleware for logging, with the intention of linking this as we approach production.

What is the best way to try and fix this issue in IIS 8 on Windows 2012 R2 using the Kestrel.NET core server?

+6
source share
6 answers

Just edit your web.config file and set the parameter stdoutLogEnabled="true"to true, and also specify the path to which the log file will be written.

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

, .

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

" " appsettings.json,

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

. Entity Framework Core 1.1, Lazy Loading. "--".

EFCore 1.1 -- , . JSON Serializer , , .

, , Startup.cs ConfigureServices(). services.AddMvc(); :

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

Kestrel . , web.config stdoutLogEnabled :

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

startup.cs :

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

Startup.cs : services.AddMvc() :

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

startup.cs, .

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

Entity Framework Core ( ).

0

I know this was flagged as an answer, but none of the above helped me. For me, the solution was to upgrade the web project from dotnet core 2.1 to 2.2, as well as update the core dot core SDK.

0
source

Source: https://habr.com/ru/post/1665900/


All Articles