Link to home
Start Free TrialLog in
Avatar of JCM0165

asked on redirect http <--> https without absolute url

There are 1-3 pages in my app I need secure. How can I have the pages automatically go to https for those pages only without using an absolute url in the redirect?

Thanks in advance.
Avatar of OriNetworks

I work with C# so here is the code for C#. If you know C# and VB.NET you should be able to easily convert this.

All its doing is looking at the request variable

//if not secure connection
  //then replace http: in the URL with https:
  string redirectUrl = Request.Url.ToString().Replace("http:", "https:"); 
 //now go to the new secure URL

Open in new window

Avatar of OriNetworks

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of JCM0165


Great, that works on going to that page, so it's half the battle.
The other half is, what can I do with the reponse.redirects to relative links going from the secure page to other pages? In this case I want to switch from https back to http.
any pages goin back to http, you can either add a reverse type of code on all of the other pages or hard code each of the links on the https page to say