2016-06-10 149 views
3

我正在使用MVC在ASP.NET核心上构建应用程序。我也在我的应用程序中使用Identity和Entity 7框架。 我正在Microsoft Azure上运行应用程序,该应用程序应附带HTTPS证书。HTTP错误310 ERR_TOO_MANY_REDIRECTS with RequireHttpsAttribute ASP.NET Core

我使用这个代码

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

我的问题,使我Startup.cs HTTPS是,当我访问网络应用程序,我得到一个310 HTTP响应ERR_TOO_MANY_REDIRECTS。我已经尝试清除我的Cookie并将网络应用重新发布到Azure,但这些都没有解决。

当我禁用上述代码时,我的应用程序在Azure上工作。当我在浏览器中手动输入https://时,我会得到一个安全的HTTPS连接。

回答

2

我的应用程序遇到同样的问题。

请检查您的Startup.csConfigure方法。在那里你应该包括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。

+0

这是为asp.net核心rc1而不是rc2 –

+0

这个问题没有指定,但我*认为*给出了问题的日期,被问到它可能是关于RC2而不是RC1。我在RC2中遇到了同样的问题,但并没有混淆事物,因为这里有一个RC1的答案,我在这里特别提到了关于RC2的问题:http://stackoverflow.com/questions/37954796/requirehttpsattribute-with-netcore -rc2-原因-HTTP302重定向 - 环 - 上天青?noredirect = 1#comment63383388_37954796 – VaticanUK

相关问题