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

  1. Teşekkürler Oğuzhan Bey bu çözüm öneriniz ASP.NET CORE 6 projemdeki ERR_TOO_MANY_REDIRECTS hatasını çözmemde yardımcı oldu. Elinize sağlık. İyi çalışmalar diliyorum.