Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

force ssl problem 1

Status
Not open for further replies.

dalec

Programmer
Jul 8, 2000
191
US
I've been trying to write a script that requires a page to use ssl, but, when I place the code at the top of each page (like the example microsoft has) when I try to navigate to the page it seems like it's stuck in a loop trying to redirect, then finally it will end up with a plain white screen. I tried the file settings in IIS and then I get a secure connect error. SSL is correctly configured, I just can't force it and I need to.

If I remove the scripts and type https:// (url) it shows secure, but, that also allows the http:// (url) protocol as well.

Anybody else have this problem? I've been through some many itterations of this, my hope is that someone will have something else I can try.

Thanks in advance.
Dale
 
<%
If Request.ServerVariables("SERVER_PORT")=80 Then
Dim strSecureURL
strSecureURL = " strSecureURL = strSecureURL & Request.ServerVariables("SERVER_NAME")
strSecureURL = strSecureURL & Request.ServerVariables("URL")
Response.Redirect strSecureURL
End If
%>
 
Or maybe you could add some sort of flag to the url in the form of a QueryString parameter...

Code:
<%
If (Request.QueryString("Foo") = "Bar") Then
  Response.Write "I give up!"
  Respnse.End
End If

If Request.ServerVariables("SERVER_PORT")=80 Then
  Dim strSecureURL
  strSecureURL = "[URL unfurl="true"]https://"[/URL]
  strSecureURL = strSecureURL & Request.ServerVariables("SERVER_NAME")
  strSecureURL = strSecureURL & Request.ServerVariables("URL")

  If (InStr(strSecureURL, "?") > 0) Then
    strSecureURL = strSecureURL & "&Foo=Bar"
  Else
    strSecureURL = strSecureURL & "?Foo=Bar"
  End If
 
  Response.Redirect strSecureURL
End If
%>
 
Sheco,

First off, thank you for your help!! Ok, I tried that script and it does load changing from http to https, which is great, but, the rest of the page doesnt load (it just comes up with "I give up!". I'm not trying to be incredibly dense, but, how do I get it to now finish loading the rest of the page??

thanks Again,
Dale
 
Here is what worked:

Code:
<%
If (Request.QueryString("Foo") <> "Bar") Then
   If Request.ServerVariables("SERVER_PORT")=80 Then
     Dim strSecureURL
     strSecureURL = "[URL unfurl="true"]https://"[/URL]
     strSecureURL = strSecureURL & Request.ServerVariables("SERVER_NAME")
     strSecureURL = strSecureURL & Request.ServerVariables("URL")
     If (InStr(strSecureURL, "?") > 0) Then
       strSecureURL = strSecureURL & "&Foo=Bar"
     Else
       strSecureURL = strSecureURL & "?Foo=Bar"
     End If
     Response.Redirect strSecureURL
   else
     Response.End()
   End If 
End If
%>

Thanks again!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top