Shalabh Mishra
Shalabh Mishra

Reputation: 44

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

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?

Upvotes: 0

Views: 104

Answers (1)

Jason Pan
Jason Pan

Reputation: 21883

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

Upvotes: 1

Related Questions