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.
--
Alan Moseley IT Consultancy
http://www.amitc.co.uk
If I have solved your problem, please click Yes below. Thanks.
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
> Alan Moseley wrote:
>> 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 = ""
"As" is not ASP vbscript!
>> If Not Request.IsSecureConnection Then
Request.IsSecureConnection is not classic ASP, I think.
>> strURL = Request.Url.AbsoluteUri.Replace("http://", "https://")
This some kind of Javascriptlike VBscript, perhaps asp.net?
calssic ASP-vbscript:
strURL = Replace(strURL,"http://", "https://")
>> Response.Redirect(strURL, True)
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.
>> End If
>>
>> On IE the page never loads, and on Firefox I get a message stating
>> that the redirection limit has been exceeded.
Strange, but you are mixing serverside and clientside terminology.
Better show your errors, to see if they are serverside or browser errors.
>> Have I inadvertently caused a loop, and if so, why? Many thanks in
>> advance.
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!
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
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.
--
HTH,
Bob Barrows