Home IIS/ASP.NET - Infinite redirects in deployed code
Reply: 0

IIS/ASP.NET - Infinite redirects in deployed code

user1551
1#
user1551 Published in July 16, 2018, 2:46 am

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?
Notes on test vs production:

  • Test is IIS 10 on Windows 10.
  • Production is IIS 6 on Windows Server 2003 R2.
  • Test uses a self-signed SSL cert.
  • Production uses a fully trusted SSL cert.
  • Identical web.configs

ASPX Markup:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SecurePage.aspx.cs" Inherits="wwwroot.SecurePage" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            This page is secure!
        </div>
    </form>
</body>
</html>

CODE-BEHIND:

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://"));
        }
    }
}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.311193 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO