Automatically toggle between https and http

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default Automatically toggle between https and http

    Hi,

    Is this possible:

    Have a seperate folder that just contains the aspx webforms that you
    require to run under SSL https. (Set IIS directory permissions up for
    this folder to be used for SSL)

    Then have a default webform page with a button on it with this code:

    Response.Redirect("Special_SSL_Folder/SSLPage.aspx")

    When you are redirected, the browser "automatically" uses httpS,
    rather than http. (Based on the IIS directory permissions set up for
    SSL on this folder.)

    Then, on the SSL webform page, you have another button on it with this
    code:

    Response.Redirect("../Non_SSL_Folder/NormalPage.aspx") 'Go back to
    http

    When you are redirected, the browser "automatically" drops the secure
    SSL https connection, and you are back to using http again. (Because
    the webforms inside the Non_SSL_Folder doesn't have SSL https settings
    set under IIS.)

    Is this possible?

    Many thanks for any information.

    Best regards from Frameworker.
    Framework fan Guest

  2. Similar Questions and Discussions

    1. How to automatically change from httpS to http for a specific folder??
      There are great instructions on the web for force HTTPS for specific folder How to automatically change from http to https for a specific folde...
    2. Switching Between HTTP and HTTPS
      Hi I wish to have a web site that has most of the pages as normal HTTP pages but has some areas that use HTTPS. I want to have it that if a user...
    3. http to https
      Is there a coldfusion function that determines the gives me the protocol of the address bar(http, https) .I tried GetHttpRequestData, but I do not...
    4. PHP won't parse under https, but will with http
      I'm not sure if this is the right forum for this question, but I'm hoping someone can help nonetheless. :) I installed an SSL Cert. on a site the...
    5. HTTPS to HTTP
      When I am using server-side button to switch from https to http by using response.redirect "http://a.apsx" in response to the client event, I am...
  3. #2

    Default Re: Automatically toggle between https and http

    Here's an excellent article (with complete source code) about
    switching between http and https automatically. I have successfully
    used it on a production web site.

    [url]http://www.codeproject.com/aspnet/WebPageSecurity.asp[/url]

    --
    Sean Winstead
    [url]http://www.componentscience.net[/url]
    Sean Winstead Guest

  4. #3

    Default Re: Automatically toggle between https and http

    I have solved my problem.

    For any aspx webform that you want to use for SSL, put this inside the
    Page_Init function:

    Response.Buffer = True
    If (Request.ServerVariables("HTTPS") = "off") Then
    Dim xredir__, xqstr__ As String

    xredir__ = "https://" &
    Request.ServerVariables("SERVER_NAME") & _

    Response.ApplyAppPathModifier(Request.ServerVariab les("SCRIPT_NAME"))
    xqstr__ = Request.ServerVariables("QUERY_STRING")

    If xqstr__ <> "" Then xredir__ = xredir__ & "?" & xqstr__

    Response.Redirect(xredir__)
    End If

    Then, for all your other aspx webforms that don't require SSL, put
    this inside the Page_Init function:

    Response.Buffer = True
    If (Request.ServerVariables("HTTPS") = "on") Then
    Dim xredir__, xqstr__ As String

    xredir__ = "http://" &
    Request.ServerVariables("SERVER_NAME") & _

    Response.ApplyAppPathModifier(Request.ServerVariab les("SCRIPT_NAME"))
    xqstr__ = Request.ServerVariables("QUERY_STRING")

    If xqstr__ <> "" Then xredir__ = xredir__ & "?" & xqstr__

    Response.Redirect(xredir__)
    End If

    Please notice the use of the ApplyAppPathModifier method. This is
    used in order to preserve session state if you are using the
    cookieless option.

    Most of the code above was taken from the 4guysfromrolla site. I just
    put the code inside the code behind section, rather than using <% %>
    inside html. Also, I noticed the use of the ApplyAppPathModifier
    method inside another thread in the .net newsgroups, and I needed it
    because I use cookieless state.

    -Frameworker.


    [email]tempframeworkfan@hotmail.com[/email] (Framework fan) wrote in message news:<f109ac80.0404010247.59701d5c@posting.google. com>...
    > Hi,
    >
    > Is this possible:
    >
    > Have a seperate folder that just contains the aspx webforms that you
    > require to run under SSL https. (Set IIS directory permissions up for
    > this folder to be used for SSL)
    >
    > Then have a default webform page with a button on it with this code:
    >
    > Response.Redirect("Special_SSL_Folder/SSLPage.aspx")
    >
    > When you are redirected, the browser "automatically" uses httpS,
    > rather than http. (Based on the IIS directory permissions set up for
    > SSL on this folder.)
    >
    > Then, on the SSL webform page, you have another button on it with this
    > code:
    >
    > Response.Redirect("../Non_SSL_Folder/NormalPage.aspx") 'Go back to
    > http
    >
    > When you are redirected, the browser "automatically" drops the secure
    > SSL https connection, and you are back to using http again. (Because
    > the webforms inside the Non_SSL_Folder doesn't have SSL https settings
    > set under IIS.)
    >
    > Is this possible?
    >
    > Many thanks for any information.
    >
    > Best regards from Frameworker.
    Framework fan Guest

  5. #4

    Default Re: Automatically toggle between https and http

    Thanks a lot for that article link Sean - very interesting.

    Sean Winstead <sean_at_componentscience_dot_net> wrote in message news:<3edo60lhl5kg71p3ac6g6csdae417fduc0@4ax.com>. ..
    > Here's an excellent article (with complete source code) about
    > switching between http and https automatically. I have successfully
    > used it on a production web site.
    >
    > [url]http://www.codeproject.com/aspnet/WebPageSecurity.asp[/url]
    Framework fan Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139