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").
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].
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)
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.
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:
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")
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
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.
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?
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
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.
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; }
}
}
}
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:
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)
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
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].
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)
Which Umbraco version and .NET Version do you use?
Thomas
Hi Thomas. Thanks for replying so quickly!
I'm using .Net v2.0 and umbraco v 4.0.2.1
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
Thanks for looking at it for me Thomas. I'll keep fiddling with it.
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:
And the redirect to https does not occur. Any idea what I'm doing wrong?
Thanks,
Jack
Hi Jack, I will take a look into it this evening...
Cheers, Thomas
Hi Thomas, trying not to be a pain, but did you get a chance to look at this?
Thanks,
Jack
Did miss it, sorry, will do it asap...
Thomas
Hi Jack,
the output
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
Or change the value of ForceHttpsValue to the integer ID of the prevalue...
Thomas
Thomas, Thank you! That helped a lot. I have it working now. :-)
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
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
Thanks Thomas - I understand now. Umbraco.dll was mentioned at the top of this thread and that confused me. I'm implementing it now.
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
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
Hey Jay,
Did this ever get updated and working on 4.5? Could you send me that code?
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
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.
is working on a reply...