HTTP Error 310 ERR_TOO_MANY_REDIRECTS with RequireHttpsAttribute ASP.NET Core

喜欢而已 提交于 2020-01-04 04:39:29

问题


I'm building an application on ASP.NET core using MVC. I'm also using the Identity and Entity 7 framework in my application. I'm running the application on Microsoft Azure which should come with a HTTPS certificate.

I'm enabling HTTPS in my Startup.cs using this code

services.AddMvc(options =>
        {
            #if !DEBUG
            options.Filters.Add(new RequireHttpsAttribute());
            #endif
        });

My problem is that when I visit the web app I get a 310 HTTP ERR_TOO_MANY_REDIRECTS response. I already tried to clear my cookies and re-publish the web app to Azure but none of these work out.

When I disable the above code my application works on Azure. When I then manually type https:// in the browser I get a secure HTTPS connection.


回答1:


I've had the same problem with my applicaton.

Please check your Startup.cs Configure method. In there you should have included app.UseIISPlatformHandler();.

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public async void Configure(IApplicationBuilder app)
{
    .....

    app.UseIISPlatformHandler();

    .....
}

The RequireHttpsAttribute uses this IISPlatformHandler for enabling HTTPS on your website.



来源:https://stackoverflow.com/questions/37745874/http-error-310-err-too-many-redirects-with-requirehttpsattribute-asp-net-core

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!