Copied to clipboard

Flag this post as spam?

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


  • Thomas Höhler 1237 posts 1709 karma points MVP
    Nov 05, 2009 @ 17:12
    Thomas Höhler
    3

    Installation

    For installation by foot just add the dll into the bin folder. Inside the dll is a usercontrol implemented but without an ascx file. So, if you want to use the control in an macro just create a new macro and enter for the "or .NET Custom Control" properties the following values:

    • "TH.Utils4Umbraco" for the assembly
    • "TH.Utils4Umbraco.CheckSsl" for the type

    After that you can (you don't have to) expose the properties in the macro via "Browse Properties". (See also the two screenshots of the project)

    • The property "PropertyAlias" defines the property alias which the controls checks for the values of the ForceSsl properties. Default value (set in the code) is "CheckSSL".
    • The property "ForceHttpsValue" defines the value which will cause the control to redirect to an https connection if it isn't a secure one. Default (also set in the code) is "ForceHttps"
    • The property "ForceHttpValue" defines the value which will cause the control to redirect to an http connection if it is a secure one. Default (also set in the code) is "ForceHttp"
    • The property "UseBothValue" defines the value which will cause the control to nothing ;-). Default (also set in the code) is "UseBoth"

    After that you can add the macro to the master template.

    For the editors you have to create a new generic property. Best practice is to add a new datatype where you take DropDownList as the render control and where you add three values ("ForceHttps", "ForceHttp" and "UseBoth").

    hth,
    Thomas

  • Shaun 248 posts 475 karma points
    Nov 26, 2009 @ 11:39
    Shaun
    0

    Hi.

    I've downloaded the zipfile and extracted "umbraco.dll" from it, which I have placed in the bin directory of my site.

    I've created a new macro and added the .Net custom control assembly and type as shown above.

    However,when I click "Browse Properties" I see this. What have I done wrong?

    Error reading TH.Utils4Umbraco

    The following list shows the Public Properties from the Control. By checking the Properties and click the "Save Properties" button at the bottom, umbraco will create the corresponding Macro Elements.

     

    System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Inetpub\harlowintranet\bin\TH.Utils4Umbraco.dll' or one of its dependencies. The system cannot find the file specified. File name: 'file:///C:\Inetpub\harlowintranet\bin\TH.Utils4Umbraco.dll' at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, StackCrawlMark& stackMark) at System.Reflection.Assembly.LoadFrom(String assemblyFile) at umbraco.developer.assemblyBrowser.Page_Load(Object sender, EventArgs e) WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

  • Shaun 248 posts 475 karma points
    Nov 26, 2009 @ 11:51
    Shaun
    0

    I've opened up the TH.Utils4Umbraco solution and built it, generating the TH.Utils4Umbraco.dll, which I've uploaded to the bin directory of the site.

    Now when I click "browse properties" I see the following.

    Error reading TH.Utils4Umbraco

    The following list shows the Public Properties from the Control. By checking the Properties and click the "Save Properties" button at the bottom, umbraco will create the corresponding Macro Elements.

     

    System.NullReferenceException: Object reference not set to an instance of an object. at umbraco.developer.assemblyBrowser.Page_Load(Object sender, EventArgs e)

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

    Which Umbraco version and .NET Version do you use?

    Thomas

  • Shaun 248 posts 475 karma points
    Nov 26, 2009 @ 13:04
    Shaun
    0

    Hi Thomas. Thanks for replying so quickly!

    I'm using .Net v2.0 and umbraco v 4.0.2.1

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

    Hi Shaun, I cannot reproduce your error. All is working fine on my test install. Just a thought: did you check the permissions for the dll? seems that it cannot be read from umbraco.

    Thomas

  • Shaun 248 posts 475 karma points
    Nov 26, 2009 @ 18:09
    Shaun
    0

    Thanks for looking at it for me Thomas. I'll keep fiddling with it.

     

     

  • Jack Wheeler 10 posts 30 karma points
    Apr 06, 2010 @ 23:09
    Jack Wheeler
    0

    Using umbraco v 4.0.2.1 / dotnet 2.0

    I'm having trouble getting this to work. I've followed the installation instructions, and my Macro properties match the screenshots. I've added the macro to my master template (does it matter where this gets inserted in the template?). I've created the new datatype as a dropdown with the three values listed. I've added this as a property to the document type. When I publish the page and view in a browser, the properties are output as text as follows:

    PropAlias: CheckSSL <br />ForceHttpsValue: ForceHttps <br />ForceHttpValue: ForceHttp <br />UseBothValue: UseBoth <br />

    And the redirect to https does not occur. Any idea what I'm doing wrong?

    Thanks,

    Jack

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Apr 07, 2010 @ 12:20
    Thomas Höhler
    0

    Hi Jack, I will take a look into it this evening...

    Cheers, Thomas

  • Jack Wheeler 10 posts 30 karma points
    Apr 09, 2010 @ 23:38
    Jack Wheeler
    0

    Hi Thomas, trying not to be a pain, but did you get a chance to look at this?

    Thanks,

    Jack

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Apr 12, 2010 @ 09:27
    Thomas Höhler
    0

    Did miss it, sorry, will do it asap...

    Thomas

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Apr 12, 2010 @ 16:52
    Thomas Höhler
    0

    Hi Jack,

    the output

    PropAlias: CheckSSL <br />ForceHttpsValue: ForceHttps <br />ForceHttpValue: ForceHttp <br />UseBothValue: UseBoth <br />

    is a debug output I didn't uncomment in the code (my fault).

    Did you make a new generic property for the document type which you are using to check the SSL? The output has to be the TextValue you entered. So In Your case you have to have a gen prop named "CheckSSL" with the internal value "ForceHttps" to force the SSL. If you are using a DropDownList for this pls check the database type of this datatype (you have to set it to "NVARCHAR" or "NTEXT").

    If this didn't work: Can I get access to the installation that I can take a closer look? (mail me to "th |at| thoehler |dot| com")

    hth, Thomas

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Apr 12, 2010 @ 16:53
    Thomas Höhler
    0

    Or change the value of ForceHttpsValue to the integer ID of the prevalue...

    Thomas

  • Jack Wheeler 10 posts 30 karma points
    Apr 13, 2010 @ 02:18
    Jack Wheeler
    0

    Thomas, Thank you! That helped a lot. I have it working now. :-)

  • Jay Hamlin 7 posts 27 karma points
    Apr 20, 2010 @ 01:23
    Jay Hamlin
    0

    Hi,
    I'm pretty new to this and have a question. I've downloaded the package and looked inside. Question is - " I already have a dll in my bin dir called umbraco.dll" - should I overwrite it with one from the package?
    I'm running 4.0.3
    Jay

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Apr 20, 2010 @ 15:14
    Thomas Höhler
    0

    No, seems that you have downloaded the Solution not the package.

    Sorry for the confusion. The package File is the "TH.Utils4Umbraco.zip" file which includes only th TH.Utils4Umbraco.dll which is the only file you have to copy to the bin folder if you are doing it by hand.

    hth, Thomas

  • Jay Hamlin 7 posts 27 karma points
    Apr 20, 2010 @ 21:55
    Jay Hamlin
    0

    Thanks Thomas - I understand now. Umbraco.dll was mentioned at the top of this thread and that confused me. I'm implementing it now.

     

  • Jay Hamlin 7 posts 27 karma points
    Apr 20, 2010 @ 23:55
    Jay Hamlin
    0

    Hi Thomas,

    I'm having problems similar to those experienced by Jack.
    I've added the datatype, added the custom prop to the pages I want redirected to https -
    however regardless of how I insert the macro
    a) it displays the alias and properties
    b) doesn't redirect the pages to https

    In your last posting to Jack you suggest - "Or change the value of ForceHttpsValue to the integer ID of the prevalue" --- not sure what you mean by that and if that's what fixed it.

    How do I insert the macro so it won't display the alias and properties?

    Thanks for your help.
    Jay

  • Jay Hamlin 7 posts 27 karma points
    Apr 21, 2010 @ 22:18
    Jay Hamlin
    0

    Hi Thomas,

    Well I got it to work and it does just what I need it to do!! Thanks for putting this together.
    I had to enlist Jack's aid - (he and I live on the same longitude!) and after talking we figured out what all needed to be done. The debug lines did need to be removed, so I'll send you an email with the fixes and some screen shots - hopefully you can update the package so others can benefit.
    Thanks -
    Jay

     

  • Nate 143 posts 184 karma points
    Sep 25, 2010 @ 18:51
    Nate
    0

    Hey Jay,

    Did this ever get updated and working on 4.5?  Could you send me that code?

  • Jack Wheeler 10 posts 30 karma points
    Nov 24, 2010 @ 23:45
    Jack Wheeler
    0

    Hi Thomas,

    After re-working my project, I had to re-install Force SSL. I have it working, but again, it's out-putting the debug code (I downloaded the latest version, 1.0). Is there a newer version of the package with this debug code commented out? I do not recall how I worked around this the last time around!

    Again, the package is working, but it still out-puts the debug code.

    edit: I found my answer, I re-built the solution with the code commented out. It's working. 

    Thanks!

    Jack

  • JHaas 7 posts 27 karma points
    Nov 19, 2011 @ 00:51
    JHaas
    0

    Current package spits out public property information when inserted into a template, no matter what I did. I've modified it to have that debug info tickable.

    using System;
    using umbraco.presentation.nodeFactory;
    
    namespace TH.Utils4Umbraco
    {
        public class CheckSsl: System.Web.UI.UserControl
        {
    
            private string propertyAlias = "CheckSSL";
            private string forceHttpsValue = "ForceHttps";
            private string forceHttpValue = "ForceHttp";
            private string useBothValue = "UseBoth";
            private bool   useDebug = false;
    
            protected override void OnLoad(EventArgs e)
            {
                base.OnLoad(e);
    
                if (useDebug)
                {
                    Response.Write("PropAlias: " + PropertyAlias + " <br />");
                    Response.Write("ForceHttpsValue: " + ForceHttpsValue + " <br />");
                    Response.Write("ForceHttpValue: " + ForceHttpValue + " <br />");
                    Response.Write("UseBothValue: " + UseBothValue + " <br />"); 
                }
    
                var node = Node.GetCurrent();
                if (node == null) 
                    return;
                var property = node.GetProperty(PropertyAlias);
                if (property == null || string.IsNullOrEmpty(property.Value)) 
                    return;
                if (property.Value == UseBothValue)
                    return;
                if (property.Value == ForceHttpsValue && !Request.IsSecureConnection)
                    Response.Redirect(Request.Url.ToString().ToLower().Replace("http:", "https:"), true);
                if (property.Value == ForceHttpValue && Request.IsSecureConnection)
                    Response.Redirect(Request.Url.ToString().ToLower().Replace("https:", "http:"), true);
            }
    
            public string PropertyAlias 
            {
                get { return propertyAlias; }
                set { propertyAlias = string.IsNullOrEmpty(value) ? "CheckSSL" : value; }
            }
            public string ForceHttpsValue
            {
                get { return forceHttpsValue; }
                set { forceHttpsValue = string.IsNullOrEmpty(value) ? "ForceHttps" : value; }
            }
            public string ForceHttpValue
            {
                get { return forceHttpValue; }
                set { forceHttpValue = string.IsNullOrEmpty(value) ? "ForceHttp" : value; }
            }
            public string UseBothValue
            {
                get { return useBothValue; }
                set { useBothValue = string.IsNullOrEmpty(value) ? "UseBoth" : value; }
            }
            public bool UseDebug {
                get { return useDebug; }
                set { useDebug = value; }
            }
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft