-- AspNet MVC/Core

Asp.net core https redirect ERR_TOO_MANY_REDIRECTS (on IIS)

Hi,

Your project after you deploy on IIS; when you want to do http to https redirect;
“ERR_TOO_MANY_REDIRECTS” brush up against.

For Solution add in startup.cs;

public void ConfigureServices(IServiceCollection services)
{
  services.Configure<ForwardedHeadersOptions>(options =>
            {
                options.ForwardedHeaders = ForwardedHeaders.XForwardedProto;
            });
  services.AddHttpsRedirection(opts => {
                opts.RedirectStatusCode = StatusCodes.Status301MovedPermanently;
                opts.HttpsPort = 443;
            });
}

and,

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

Yorumla

Yorum