Redirect Loop?

A

Alan Moseley

Please can someone put me out of my misery. I am used a shared hosting
provider to host my asp website. I need certain pages of my site to be
viewed over SSL. I have therefore inserted the following code into the
Page_Load event of a page that needs to be viewed over SSL:-

Dim strURL As String = ""
If Not Request.IsSecureConnection Then
strURL = Request.Url.AbsoluteUri.Replace("http://", "https://")
Response.Redirect(strURL, True)
End If

On IE the page never loads, and on Firefox I get a message stating that the
redirection limit has been exceeded.

Have I inadvertently caused a loop, and if so, why? Many thanks in advance.
 
D

Dooza

Alan said:
Please can someone put me out of my misery. I am used a shared hosting
provider to host my asp website. I need certain pages of my site to be
viewed over SSL. I have therefore inserted the following code into the
Page_Load event of a page that needs to be viewed over SSL:-

Dim strURL As String = ""
If Not Request.IsSecureConnection Then
strURL = Request.Url.AbsoluteUri.Replace("http://", "https://")
Response.Redirect(strURL, True)
End If

On IE the page never loads, and on Firefox I get a message stating that the
redirection limit has been exceeded.

Have I inadvertently caused a loop, and if so, why? Many thanks in advance.

I use this:

<%
If Request.ServerVariables("HTTPS") = "off" Then
Response.Redirect "https://" & Request.ServerVariables("HTTP_HOST") &
Request.ServerVariables("URL") & "?" &
Request.ServerVariables("QUERY_STRING")
End If
%>

Dooza
 
E

Evertjan.

Dooza wrote on 19 okt 2009 in microsoft.public.inetserver.asp.general:

"As" is not ASP vbscript!

Request.IsSecureConnection is not classic ASP, I think.

This some kind of Javascriptlike VBscript, perhaps asp.net?

calssic ASP-vbscript:

strURL = Replace(strURL,"http://", "https://")

Response.Redirect has only one parameter.
<http://msdn.microsoft.com/en-us/library/ms524309.aspx>

And even if it had two,
using () around them would result in an error,
as ASP statements [and functions used as statements] do not use them.

Strange, but you are mixing serverside and clientside terminology.

Better show your errors, to see if they are serverside or browser errors.

Why a loop?
I use this:

<%
If Request.ServerVariables("HTTPS") = "off" Then
Response.Redirect "https://" & Request.ServerVariables("HTTP_HOST") &
Request.ServerVariables("URL") & "?" &
Request.ServerVariables("QUERY_STRING")
End If
%>

That is classic ASP VBS!
 
B

Bob Barrows

Alan said:
Please can someone put me out of my misery. I am used a shared
hosting provider to host my asp website. I need certain pages of my
site to be viewed over SSL. I have therefore inserted the following
code into the Page_Load event of a page that needs to be viewed over
SSL:-

Dim strURL As String = ""
If Not Request.IsSecureConnection Then
strURL = Request.Url.AbsoluteUri.Replace("http://", "https://")
Response.Redirect(strURL, True)
End If
As noted by Evertjian, this does not appear to be classic ASP vbscript
code, so:

There was no way for you to know it (except maybe by browsing through
some of the previous questions before posting yours - always a
recommended practice), but this is a classic (COM-based) asp newsgroup.
ASP.Net is a different technology from classic ASP. While you may be
lucky enough to find a dotnet-savvy person here who can answer your
question, you can eliminate the luck factor by posting your question to
a newsgroup where the dotnet-savvy people hang out. I suggest

microsoft.public.dotnet.framework.aspnet.

There are also forums at www.asp.net where you can find a lot of people
to help you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top