Showing posts with label SSL. Show all posts
Showing posts with label SSL. Show all posts

Friday, April 27, 2007

Here's How you Force SSL in Creaky Old ASP

Say you have a Classic ASP site or application where you want to force a secure (SSL) connection.

Use the ASP ServerVariables collection to check the current connection, then redirect appropriately.

Copy/Paste the following into a text file and name it ForceSSL.asp:

<%

If UCase(Request.ServerVariables("HTTPS")) = "OFF" Then
'''get page
    sRedirect = "https://" & Request.ServerVariables("SERVER_NAME") &
    Request.ServerVariables("PATH_INFO") & "?" & Request.Querystring
    Response.Redirect sRedirect
End If

%>

For each page in the site/application, add a server-side include that looks like this:

<!--#include virtual="/ForceSSL.asp"-->

AG, hope this helps you out. I'm probably weeks too late.