title: IIS/ASP.NET - Infinite redirects in deployed code
body: <p>I am getting an infinite redirect loop only when I deploy my code to a Production environment.  I am attempting to force SSL on the page by using a simple code redirect.  I am running into the issue with a stripped-down old school web form (I'm stuck on .NET 3.5 for this project).  All code is below.
  Any ideas on why I would get an infinite redirect look in Production and not Test?<br>
  Notes on test vs production:</p>
  
  <ul>
  <li>Test is IIS 10 on Windows 10. </li>
  <li>Production is IIS 6 on Windows Server 2003 R2. </li>
  <li>Test uses a self-signed SSL cert.</li>
  <li>Production uses a fully trusted SSL cert.</li>
  <li>Identical web.configs</li>
  </ul>
  
  <p>ASPX Markup:</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SecurePage.aspx.cs" Inherits="wwwroot.SecurePage" %&gt;
  
  &lt;!DOCTYPE html&gt;
  
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head runat="server"&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
          &lt;div&gt;
              This page is secure!
          &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>CODE-BEHIND:</p>
  
  <pre><code>namespace wwwroot
  {
      public partial class SecurePage : System.Web.UI.Page
      {
  
          protected void Page_Load(object sender, EventArgs e)
          {
              if (!Request.Url.ToString().ToLower().StartsWith("https://"))
                  Response.Redirect(Request.Url.ToString().ToLower().Replace("http://", "https://"));
          }
      }
  }
  </code></pre>