switch to ssl automatically
February 5, 2009 by: B.HardingIn this post I’ll explain how I transparently switch from http to https
This same snipit can be put on any page as is and forces certain pages to be https. The nice thing about it is that the user can not edit the url back to http on a page that has this. All I did was put it on the login page and payment page.
On page load the server examines the Request.IsSecureConnection flag and redirects if not secure. It’s that simple. To make it a re-useble snipit I get the page name dynamically.
Be sure not to include the slash after your top level domain.
If Not Page.IsPostBack Then
If Not Request.IsSecureConnection Then
Response.Redirect(“https://www.yourhostname.com” & Request.Url.PathAndQuery.ToString)
End If
End If


