Tuesday, October 10, 2006

Redirecting the non-secure connection to secure connection

Response.Buffer = True
if Request.ServerVariables("HTTPS") = "off" then
strMethod = Request.ServerVariables("REQUEST_METHOD")
strServer = Request.ServerVariables("SERVER_NAME")
strSciptName = Request.ServerVariables("SCRIPT_NAME")
strRedirect = "https://" & strServer & StrSciptName
strQryStr = Request.Querystring

if Len(strQryStr) > 0 Then strRedirect = strRedirect & "?" & strQryStr

if strMethod = "POST" then
Response.Write "<form method=post action=" & strRedirect & " name='f'>"
for x = 1 to Request.Form.Count()
tname = Request.Form.Key(x)
tvalue = Server.HTMLEncode(Request.Form.Item(x))
Response.Write "<input type=hidden name=" & tname &amp; " value=""" & tValue & """>" & vbCrLf
next
Response.Write "<input type=submit value=Go></form>"
Response.Write "<script>" & vbCrLf
Response.Write "document.f.submit();" & vbCrLf
Response.Write "</script>"
else
Response.Redirect strRedirect
end if
end if

0 Comments:

Post a Comment

<< Home