Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gordon Saxby 1461 posts 1883 karma points
    Nov 03, 2009 @ 08:49
    Gordon Saxby
    0

    Enable SSL / HTTPS

    How do I enable SSL for a particular section of an Umbraco (v4+) site? IIS requires that you select the folder but of course, it doesn't actually exist!?

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Nov 03, 2009 @ 11:47
    Thomas Höhler
    0

    Hi Gordon, long time ago I wrote a control which check by a true/fals property if the site needed https and redirects to itself with https. the control was made for v3, but should work similiar in v4. I can give you the code (if I find it) or I can do a package ou of this if wanted.

    hth, Thomas

  • Gordon Saxby 1461 posts 1883 karma points
    Nov 03, 2009 @ 12:43
    Gordon Saxby
    0

    Hi Thomas - this seems like something that should be built into Umbraco. It's hard to believe that no one else has needed to do this!

    I could do with something fairly quickly, so either the code or a package would be greatly received :-)

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Nov 03, 2009 @ 14:04
    Thomas Höhler
    0

    Will pull it out of my data graves in the cellar this evening. huh, frightened to see that old code...

    Thomas

  • Shea Daniels 8 posts 28 karma points
    Nov 03, 2009 @ 21:44
    Shea Daniels
    0

    Gordon, I believe you could also use a URL rewriting filter like this one:

    ISAPI Rewrite

    You could then do a permanent (301) redirect to the https version of the page.

  • Andrew 142 posts 98 karma points
    Nov 03, 2009 @ 22:12
    Andrew
    0

    Hi 

    I researched this about a year ago, andthere was talk then that v4 handles this out the box. That said - we implemented a solution based upon this dll:

    http://www.codeproject.com/KB/aspnet/WebPageSecurity.aspx?fid=29017&df=90&mpp=25&noise=3&sort=Position&view=Quick&fr=101

    on the old forum there was instructions on ho to modify this for use within umbraco (couldn't find the thread). It was not difficult to do. 

    I dont seem to get notifications of comments from this forum, so email me if you would like more detail om how it was done. It Works very well for us

  • Ricky Beard 61 posts 116 karma points
    Nov 03, 2009 @ 22:35
    Ricky Beard
    1

    I usually create a true/false generic property on my base document type called "useSSL", then I drop a user control onto my master template with the following code:

    protected void Page_Load(object sender, EventArgs e)
    {
        Node n = Node.GetCurrent();
        int useSSL;
        if (n.GetProperty("useSSL") != null)
        {
            int.TryParse(n.GetProperty("useSSL").Value, out useSSL);
        }
        else
        {
            useSSL = 0;
        }
    if (useSSL > 0)
        {
            if (!Request.IsSecureConnection)
            {
                Response.Redirect(Request.Url.ToString().Replace("http:", "https:"));
            }
        }
        else
        {
            if (Request.IsSecureConnection)
            {
                Response.Redirect(Request.Url.ToString().Replace("https:", "http:"));
            }
        }
    }

    I can then individually select which pages I want to secure.

     

  • Gordon Saxby 1461 posts 1883 karma points
    Nov 04, 2009 @ 01:00
    Gordon Saxby
    0

    Ricky - did you create a ascx / dll or did you put the code directly into the template (in a script block)?

  • Ricky Beard 61 posts 116 karma points
    Nov 04, 2009 @ 02:53
    Ricky Beard
    0

    I use an ascx, but I don't see why you couldn't use a script block.

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Nov 04, 2009 @ 09:20
    Thomas Höhler
    0

    The solution from Ricky is nearly the same as mine. Additional to that code above I had a three state property (ForceHTTPS, ForceHTTP, Both) which could also redirect to non SSL.

    Thomas

  • Gordon Saxby 1461 posts 1883 karma points
    Nov 04, 2009 @ 11:11
    Gordon Saxby
    0

    Ricky - I tried putting a script block in the master template but it complained that it did not know what "Node" was?

    Thomas - I would still be interested in seeing your code as well, if you don't mind?

  • Ricky Beard 61 posts 116 karma points
    Nov 04, 2009 @ 14:52
    Ricky Beard
    0

    I am sorry, I misread your previous post.  I am not sure if you can place it in a script block in the master template itself (as opposed to a script block in a ascx file).  Did you import the correct Umbraco namespace at the top of your template?

    <%@ Import namespace="umbraco.presentation.nodeFactory" %>

    Also, are you unable to use a user control for some reason?

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Nov 05, 2009 @ 16:41
    Thomas Höhler
    0

    I have upgraded my old code (only small polishing to work with v4 umbraco items) and uploaded it as a new project: http://our.umbraco.org/projects/force-ssl

    The Solution is also added

    hth,
    Thomas

  • praveen 113 posts 164 karma points
    May 16, 2011 @ 02:18
    praveen
    0

    Hi Ricky Beard

    Umbraco: version 4.0

    OS: win 2008R2 Server

    I have tried your code and it looks good to me, now can Ricky or someone please let me know how to configure IIS7 so that only the donations page is on SSL and rest of the umbraco web site runs on http url.

    Many Thanks for your help in advance.

    Kind Regards.

Please Sign in or register to post replies

Write your reply to:

Draft