客户端套接字拒绝连接,事件管理器说 'Failed to determine the https port for redirect'?

Client Socket refusing connection and event manager is saying 'Failed to determine the https port for redirect'?

在与服务器 TCP IP 端口连接时,我在 ASP.Net 核心 MVC 操作调用中使用的客户端套接字连接代码在 IIS 服务器上为我提供了 Failed to determine the https port for redirect,而其 运行 在我与测试服务器 TCP 代码交互的本地机器上完全正常。

谁能帮我解决这个问题?

您可以尝试使用ForwardedHeadersOptions转发Startup.ConfigureServices中headers中的两个headers。

public void ConfigureServices(IServiceCollection services)
  {
      services.AddControllers();

      services.Configure<ForwardedHeadersOptions>(options =>
      {
          options.ForwardedHeaders =
              ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
      });
 ...
 ...

  }

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    app.UseForwardedHeaders();

    if (env.IsDevelopment())
    {
         app.UseDeveloperExceptionPage();
    }
    else
    {
        app.UseHsts();
    } 
}

如果不行,您也可以尝试设置环境变量ASPNETCORE_HTTPS_PORT。

更多细节请参考博客

Resolving Failed to determine the HTTPS port for the redirect