http vs https

Discussion in 'ASP .Net' started by jdp, Sep 8, 2006.

  1. jdp

    jdp Guest

    I've created an asp.net 2.0 site that has secure and non secure pages
    so, obviously, it has a login page. The web.sitemap file has the url
    set to the relative location of the page, meaning https isn't
    specified. Because my machine and any other developer will have a
    certificate installed, we get a Security Alert dialog box. Click Yes
    and get routed to the login page in https mode. User logs in and
    continues in https mode, all is fine. Here's the question. When
    sitting on the login page the first time (https is the mode), and I
    click any link in my menu, meaning any page exposed to the public, I
    can't get out of https mode! How do you toggle the mode? What
    I've tried is creating an http module that intercepts the
    PreRequestHandlerExecute method (code is below). This sort of works
    except that I have two other pages on the login page that, once on
    them, if I click in the menu, I need to get out of https mode. I was
    hoping I wouldn't have to hard code them in the second if statement.
    Can anyone shed some light on this?

    Here's the code for trying to switch modes:

    Dim ctx As HttpContext = HttpContext.Current
    If ctx.Request.IsAuthenticated = True AndAlso
    ctx.Request.IsSecureConnection = False Then
    ctx.Response.Redirect(ctx.Request.Url.ToString.Replace("http:",
    "https:"))
    Else
    If ctx.Request.IsAuthenticated = False AndAlso _
    ctx.Request.IsSecureConnection = True AndAlso _
    ctx.Request.Url.ToString.ToLower.IndexOf("webresource.axd") = -1
    AndAlso _
    Not ctx.Request.CurrentExecutionFilePath.ToLower =
    FormsAuthentication.LoginUrl.ToLower Then

    ctx.Response.Redirect(ctx.Request.Url.ToString.Replace("https:",
    "http:"))
    End If
    End If

    Any feedback is greatly appreciated!
    jdp, Sep 8, 2006
    #1
    1. Advertising

  2. jdp

    Mark Rae Guest

    Mark Rae, Sep 8, 2006
    #2
    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. aftab

    HTTP to HTTPS

    aftab, Sep 28, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    3,361
    Leon Mayne [MVP]
    Oct 3, 2004
  2. Raymond Tam

    HTTPS to HTTP

    Raymond Tam, Aug 5, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    562
    Marco Scheel
    Aug 6, 2003
  3. Axel
    Replies:
    8
    Views:
    1,060
    Adrienne Boswell
    Apr 27, 2009
  4. jotto
    Replies:
    4
    Views:
    373
    jotto
    Oct 2, 2006
  5. Naveen Dhanuka
    Replies:
    1
    Views:
    261
Loading...

Share This Page