相同的站点会产生“太多重定向".仅通过蜂窝网络,不通过WiFi [英] The same site produces "too many redirects" only via cellular, not via WiFi

查看:232
本文介绍了相同的站点会产生“太多重定向".仅通过蜂窝网络,不通过WiFi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在外部主机提供商处托管一个小型网站.当我从iPhone打开它时,根据我将iPhone连接到互联网的方式,我会得到不同的结果:

I host a small web site at an external host provider. When I open it from my iPhone, I get different results depending on how my iPhone is connected to the internet:

  • 通过WiFi建立连接后,我的页面始终会打开并按预期运行
  • 通过Cellular建立连接时,我的页面始终会产生以下错误消息:

在移动Safari上:

On mobile Safari:

Safari无法打开页面,因为发生了太多的重定向.

Safari cannot open the page because too many redirects occurred.

在移动版Chrome上:

On mobile Chrome:

此页面无法正常工作/重定向您很多次.

This page isn't working / redirected you too many times.

在Opera上:

无法访问此站点/HTTP重定向过多.

This site can't be reached / too many HTTP redirects.

据我所知,决定结果的唯一区别是互联网连接类型-WiFi与Cellular.我找不到其他区别.

As far as I can tell, the only difference that decides the outcome is the internet connection type - WiFi vs. Cellular. I cannot find any other differences.

由于该站点可以通过WiFi网络正常运行,因此我排除了站点上的重定向循环(这是最常提及的重定向过多"错误的原因).我也尝试关闭跨站点跟踪预防,但是结果保持不变.我想念什么吗?这种奇怪行为的原因可能是什么?

Since the site works fine through WiFi network, I ruled out a redirect loop on my site (that is the most commonly mentioned cause of "too many redirects" error). I also tried turning off cross-site tracking prevention, but the results remained the same. Am I missing something? What could be the cause of this strange behavior?

在适当的情况下,以下是有关网站本身的一些信息:

In case it is relevant, here are a few things about the web site itself:

  • 网站是使用ASP.NET Core开发的
  • 在两种情况下(通过WiFi和蜂窝网络),我都使用https访问网站
  • 站点位于子域中,该子域使用来自顶部"域的通配符证书
  • 站点使用ASP.NET Core脚手架式"身份验证,该身份验证使用重定向和cookie,并具有记住我"功能.

推荐答案

我终于偶然发现了一个修复程序,尽管我仍然不知道为什么该错误不会在台式机和移动WiFi连接上显现出来.问题与使用进程外模式将我的Web应用程序托管在IIS上,以及在安装过程中调用UseHttpsRedirection()有关.

I finally stumbled upon a fix, although I still do not know why the error does not manifest itself on desktops and mobile WiFi connections. The issue has to do with hosting my web application on IIS using out-of-process mode, and calling UseHttpsRedirection() during the setup.

接下来会发生什么在此答案中描述:IIS,它连接到我的进程外主机(Kestrel) )通过http重定向,然后我手机上的浏览器以某种方式检测到它.还有第二种重定向(合法的重定向)到登录页面,电话浏览器也将其计算在内.现在,手机浏览器会看到两次重定向,因此显示错误,因为最多允许一次重定向.

What happens next is described in this answer: IIS, which connects to my out-of-process host (Kestrel) via http, gets redirected, and the browser on my phone somehow detects it. There is also a second redirection (the legitimate one) to the login page, which the phone browser counts as well. Now the phone browser sees two redirections, so it displays an error, because at most one redirection is allowed.

解决方法是简单地删除对UseHttpsRedirection()的调用.在进程外托管方案中,这是不必要的:IIS front被配置为需要https,因此无论如何客户端都将被重定向.

The fix was simply to remove the call to UseHttpsRedirection(). It was unnecessary in out-of-process hosting scenario: IIS front is configured to require https, so clients get redirected anyway.

这篇关于相同的站点会产生“太多重定向".仅通过蜂窝网络,不通过WiFi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆