VB code
If Not Request.IsLocal AndAlso Not Request.IsSecureConnection Then
Dim redirectUrl As String = Request.Url.ToString().Replace("http:", "https:")
Response.Redirect(redirectUrl)
End If
C# code
if (!Request.IsLocal && !Request.IsSecureConnection)
{
string redirectUrl = Request.Url.ToString().Replace("http:", "https:");
Response.Redirect(redirectUrl);
}
Classic asp Read more...
'do https stuff
dim httpsStuff
httpsStuff = Request.ServerVariables("PATH_INFO")
if Request.ServerVariables("QUERY_STRING") <> "" then
httpsStuff = httpsStuff & "?" & Request.ServerVariables("QUERY_STRING")
end if
if instr(httpsStuff,"/login.asp") OR
instr(httpsStuff,"check_user.asp") OR
instr(httpsStuff,"/admin_login.asp") OR
instr(httpsStuff,"/reset_password.asp") OR
instr(httpsStuff,"/new_user.asp") OR
instr(httpsStuff,"/personal_info.asp") OR
instr(httpsStuff,"/search.asp") OR
instr(httpsStuff,"/usr_detail_info.asp") then
if lcase(request.ServerVariables("HTTPS")) = "off" then
response.redirect("https://www.mywebsite.com" & httpsStuff)
end if
else
if lcase(request.ServerVariables("HTTPS")) = "on" then
response.redirect("http://www.mywebsite.com" & httpsStuff)
end if
end if