Home > Back-end >  Client Socket refusing connection and event manager is saying 'Failed to determine the https po
Client Socket refusing connection and event manager is saying 'Failed to determine the https po

Time:04-21

While connecting with the Server TCP IP Port the Client socket connection code which I have used in ASP.Net Core MVC Action call is giving me Failed to determine the https port for redirect on the IIS Server while its running perfectly fine on local machine where I had interacted with a Test Server TCP code.

Can anyone help me in this issue?

CodePudding user response:

You can try to use the ForwardedHeadersOptions to forward the two headers in the headers in Startup.ConfigureServices.

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

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

  }

And

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

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

If it not works for you, you also can try to set the environment variable ASPNETCORE_HTTPS_PORT.

For more details, please refer blow blogs.

Resolving Failed to determine the HTTPS port for the redirect

  • Related