Friday, October 30, 2009

Force ASP.NET page to load using https

Today a customer reported that a site they made was hosted with GoDaddy and they had obtained a certificate.  Now the question was, how to make certain pages load only as secure.

Godaddy's suggestion involved a 301 redirect - thanks but no thanks.

We stumbled onto this page that simply answered the question.
If Not Request.IsSecureConnection Then
Response.Redirect("https://www.domain.com/yourpage.aspx")
End If

For a noob that would be - in every .aspx page you want to load using your new SSL Cert add the above line right after:

<script runat="server">

Sub Page_load()

No comments:

Post a Comment