So in my code I want to detect if my login page is being called http, and redirect it to https.
I know there are non code ways to skin this cat, but for frustrating technical reasosn I'm backed into doing it in code.
if (!Request.IsSecureConnection) { string redirectUrl = Request.Url.ToString().Replace("http:", "https:"); Response.Redirect(redirectUrl); }
So I drop this in my Page_Load(...)
, make sure my debugger uses real IIS, not VS2008s IIS, and hit debug.
Inthe debugger, waltz along, hit Response.Redirect("https://localhost/StudentPortal3G/AccessControl/AdLogin.aspx"), hit f5.
Get "Internet Explorere Cannot Display the webpage, url is HTTP, not HTTPS.Not getting an informative error... same thing happens not running in the debugger.
So what am I missing? it does not appear to be rocket science, I've seen similar code on lots of blogs...
What am I doing wrong? I figure it has to be a totally obvious Rookie mistake, but I'm not seeing it.