Connecting Tech Pros Worldwide Forums | Help | Site Map

Using ASP to capture a query string and redirect to SSL

Nuevo
Guest
 
Posts: n/a
#1: Jul 20 '06
I am looking for some method to capture, into a variable, the entire URL of
an http request and redirect to SSL. For example, if a user opens a browser
and typed in

http://myserver.com/application/some...893bdgt0248991

I want to be able to redirect to an SSL connection

httpS://myserver.com/application/som...893bdgt0248991

Your help is appreciated.



Mike Brind
Guest
 
Posts: n/a
#2: Jul 20 '06

re: Using ASP to capture a query string and redirect to SSL



Nuevo wrote:
Quote:
I am looking for some method to capture, into a variable, the entire URL of
an http request and redirect to SSL. For example, if a user opens a browser
and typed in
>
http://myserver.com/application/some...893bdgt0248991
>
I want to be able to redirect to an SSL connection
>
httpS://myserver.com/application/som...893bdgt0248991
>
Your help is appreciated.
<%
url = "https://myserver.com/application/some.asp?"
qrystr = ""
For Each x In Request.QueryString
qrystr = qrystr & "&" & x & "=" & Request.QueryString(x)
Next

strRedirect = url & right(qrystr,len(qrystr)-1)

Response.Redirect strRedirect
%>

--
Mike Brind

Mark J. McGinty
Guest
 
Posts: n/a
#3: Jul 21 '06

re: Using ASP to capture a query string and redirect to SSL



"Nuevo" <imaneophyte@gmail.comwrote in message
news:OGzfrkDrGHA.4680@TK2MSFTNGP02.phx.gbl...
Quote:
>I am looking for some method to capture, into a variable, the entire URL of
>an http request and redirect to SSL. For example, if a user opens a browser
>and typed in
>
http://myserver.com/application/some...893bdgt0248991
>
I want to be able to redirect to an SSL connection
>
httpS://myserver.com/application/som...893bdgt0248991
>
Your help is appreciated.
This expression should get everything but the protocol from the original
URL, including the server's host name, file name and any directory info that
may have been included:

Url = Request.ServerVariables("SERVER_NAME") & _
Request.ServerVariables("URL") & "?" & _
Request.ServerVariables("QUERY_STRING")

Response.Redirect "https://" & Url


-Mark






Justin Piper
Guest
 
Posts: n/a
#4: Jul 21 '06

re: Using ASP to capture a query string and redirect to SSL


On Thu, 20 Jul 2006 15:28:29 -0500, Mike Brind <paxtonend@hotmail.com>
wrote:
Quote:
<%
url = "https://myserver.com/application/some.asp?"
qrystr = ""
For Each x In Request.QueryString
qrystr = qrystr & "&" & x & "=" & Request.QueryString(x)
Next
>
strRedirect = url & right(qrystr,len(qrystr)-1)
>
Response.Redirect strRedirect
%>
You can actually use the QueryString collection as a scalar rather than
iterating through it:

<% Option Explicit %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<title>Default</title>
<p><%= Server.HtmlEncode(Request.QueryString) %></p>

--
Justin Piper
Bizco Technologies
http://www.bizco.com/
Closed Thread