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