How To force ASP pages to use SSL

Using SSL in ASP Pages.

Paste following code at the top of ASP page you want to force to use SSL.

ASP Code ==>

If Request.ServerVariables("SERVER_PORT")=80 Then
strSSLURL= "https://"
strSSLURL= strSSLURL & Request.ServerVariables("SERVER_NAME")
strSSLURL= strSSLURL & Request.ServerVariables("URL")
Response.Redirect strSSLURL
End If


1. This code assumes that IIS is running with standard port addresses.
i.e. HTTP Port = 80 and HTTPS Port = 443

2. If you need to use this code is several ASP pages, paste above code in an ASP include file and refer the include file at the top of ASP page.


Share this article!

Follow us!

Find more helpful articles: