Redirect Loop?

Discussion in 'ASP General' started by Alan Moseley, Oct 19, 2009.

  1. Alan Moseley

    Alan Moseley Guest

    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.
    --
    Alan Moseley IT Consultancy
    http://www.amitc.co.uk

    If I have solved your problem, please click Yes below. Thanks.
    Alan Moseley, Oct 19, 2009
    #1
    1. Advertising

  2. Alan Moseley

    Dooza Guest

    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 = ""
    > 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
    Dooza, Oct 19, 2009
    #2
    1. Advertising

  3. Alan Moseley

    Evertjan. Guest

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

    > 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)
    Evertjan., Oct 19, 2009
    #3
  4. Alan Moseley

    Bob Barrows Guest

    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 = ""
    > 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.

    --
    HTH,
    Bob Barrows
    Bob Barrows, Oct 19, 2009
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VHJveQ==?=

    Response.redirect does not redirect from .aspx page

    =?Utf-8?B?VHJveQ==?=, Oct 18, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    5,229
    Srowe1975
    Oct 15, 2008
  2. IBCK
    Replies:
    1
    Views:
    754
  3. Sal
    Replies:
    1
    Views:
    399
  4. Ron Howard
    Replies:
    2
    Views:
    514
    Ron Howard
    Aug 11, 2004
  5. Isaac Won
    Replies:
    9
    Views:
    364
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page