使用RequireHttpsAttribute ASP.NET Core的HTTP错误310 ERR_TOO_MANY_REDIRECTS [英] HTTP Error 310 ERR_TOO_MANY_REDIRECTS with RequireHttpsAttribute ASP.NET Core
问题描述
我正在使用MVC在ASP.NET核心上构建应用程序。我也在我的应用程序中使用Identity和Entity 7框架。
我在Microsoft Azure上运行应该附带HTTPS证书的应用程序。
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.
我使用此代码在我的Startup.cs中启用HTTPS
I'm enabling HTTPS in my Startup.cs using this code
services.AddMvc(options =>
{
#if !DEBUG
options.Filters.Add(new RequireHttpsAttribute());
#endif
});
我的问题是,当我访问网络应用程序时,我得到310 HTTP ERR_TOO_MANY_REDIRECTS响应。我已经尝试清除我的cookie并将Web应用程序重新发布到Azure,但这些都没有成功。
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.
当我禁用上面的代码时,我的应用程序在Azure上运行。当我在浏览器中手动输入https://时,我会得到一个安全的HTTPS连接。
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.
推荐答案
我有同样的我的应用程序存在问题。
I've had the same problem with my applicaton.
请检查 Startup.cs
配置
方法。在那里你应该包括 app.UseIISPlatformHandler();
。
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();
.....
}
RequireHttpsAttribute使用这个IISPlatformHandler用于在您的网站上启用HTTPS。
The RequireHttpsAttribute uses this IISPlatformHandler for enabling HTTPS on your website.
这篇关于使用RequireHttpsAttribute ASP.NET Core的HTTP错误310 ERR_TOO_MANY_REDIRECTS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!