Trikks

The digital adventures of Eric Herlitz

Archive for the ‘Umbraco’ Category

No node exists with id ’0′ when using uSiteBuilder

Posted by trikks on March 30, 2013

So I’m experimenting with uSiteBuilder (from Vega IT) to bring some of my sites up to a more enterprise level. I did release the tool “Umbraco Masterpage CodeFile Fixer” in early 2012 and updated it with uSiteBuilder support recently.

In some of my experiments I got the error “No node exists with id ’0′”. Well that sucks.

My resolution

Quite simple for me since I build and deploy a separate binary with all uSiteBuilder stuff. Remove the binary from the bin folder and run the install process by navigation to http://yoursite/install/. This will setup or fix the root node. When done, you may try to place the uSiteBuilder binary in place again.

Cheers.

Posted in uSiteBuilder | Tagged: , | 2 Comments »

Get a typed object from the uComponents Url Picker

Posted by trikks on October 12, 2012

This snippet is based on Umbraco 4.9 and uComponents 5 but should work almost any verison.

uComponents for Umbraco is possibly one of the best extensions out there for any CMS and the Url Picker is one of my favorites. The data returned to the

As the documentation states (UrlPicker documentation) you get the data as xml or json.

<url-picker mode="Content">
        <new-window>False</new-window>
        <node-id>1061</node-id>
        <url>/homeorawaytest4.aspx</url>
        <link-title>Home Or Away Quiz</link-title>
</url-picker>

Snippet

I created an object that will help those of who uses c# or vb.net. Use it like this

Node CurrentNode = Node.GetCurrent();
var buyOnlineProperty = CurrentNode.GetProperty("buyOnline");
var buyOnline = new Trikks.Umbraco.UrlPicker(buyOnlineProperty);

And include this object

using System;
using System.Xml;
using umbraco.interfaces;

namespace Trikks.Umbraco
{
    public class UrlPicker
    {
        public string Url { get; set; }
        public int NodeId { get; set; }
        public string LinkTitle { get; set; }
        public bool NewWindow { get; set; }

        public UrlPicker() { }

        public UrlPicker(object property)
        {
            string propertyValue = string.Empty;

            // If IProperty
            if (property is IProperty)
            {
                propertyValue = ((IProperty) property).Value;
            }

            // If string
            if (property is string)
            {
                propertyValue = property.ToString();
            }

            if (!string.IsNullOrEmpty(propertyValue))
            {
                // Get url from xml
                XmlDocument doc = new XmlDocument();
                doc.LoadXml(propertyValue);

                var url = doc.SelectSingleNode("//url");
                if (url != null)
                    Url = url.InnerText;

                var newWindow = doc.SelectSingleNode("//new-window");
                if (newWindow != null)
                    NewWindow = Convert.ToBoolean(newWindow.InnerText);

                var nodeId = doc.SelectSingleNode("//node-id");
                if (nodeId != null && !string.IsNullOrEmpty(nodeId.InnerText))
                    NodeId = Convert.ToInt32(nodeId.InnerText);

                var linkTitle = doc.SelectSingleNode("//link-title");
                if (linkTitle != null)
                    LinkTitle = linkTitle.InnerText;
            }

        }
    }
}

Some results

Using static url

Using Content node picker

Posted in uComponents, Umbraco | 1 Comment »

Problems with uComponents Sub Tabs and getting error on GUID 2c787731-cd81-48cd-a94f-4930185bdb58?

Posted by trikks on October 11, 2012

Using uComponents in Umbraco can sometimes misbehave, this error was given to me in Umbraco 4.9 using uComponents 5.0

The full error is as follows

Could not find a IDataType control matching DataEditorId 2c787731-cd81-48cd-a94f-4930185bdb58 in the controls collection. To correct this, check the data type definition in the developer section or ensure that the package/control is installed correctly.

This means you are missing a data type from uComponents, in this case the Sub Tabs. This is since Sub Tabs wasn’t implemented in 5.0. I use it anyway but that means that I have to do the build myself and put the binaries into the bin folder of umbraco.

Problem solved!

Posted in Umbraco | Leave a Comment »

Howto fix the ‘/GetSecondsBeforeUserLogout’ error in Umbraco

Posted by trikks on October 1, 2012

In some Umbraco installations there are very frequent calls to the service

/umbraco/webservices/legacyajaxcalls.asmx/GetSecondsBeforeUserLogout

This may leave errors like this

Request format is unrecognized for URL unexpectedly ending in '/GetSecondsBeforeUserLogout'.

Here is how to fix it

Insert this in the <system.web> section of your web.config

<webServices>
    <protocols>
        <add name="HttpGet"/>
        <add name="HttpPost"/>
    </protocols>
</webServices>

A bit more detailed

<configuration>
    <system.web>
        <webServices>
            <protocols>
                <add name="HttpGet"/>
                <add name="HttpPost"/>
            </protocols>
        </webServices>
    </system.web>
</configuration>

There, it works

You may get other errors from here on, but the webservice(s) should at least be accessible

Cheers!

Posted in Umbraco | Tagged: , | Leave a Comment »

How to handle the error “Handler “PageHandlerFactory-Integrated” has a bad module “ManagedPipelineHandler” in its module list”

Posted by trikks on September 8, 2012

I did port some of my development environments to a new virtual machine with a brand new 2008 R2 Server and a Visual Studio 2012. Everything seemed fine until I tried to load one of my Umbraco labs.

The error “Handler “PageHandlerFactory-Integrated” has a bad module “ManagedPipelineHandler” in its module list” showed up.

This is quite simple to resolve for Umbraco,

  • ensure your application pool runs in .net 4 classic mode in IIS
  • run the aspnet_regiis.exe -i command, to run the aspnet_regiis command
    • navigate to C:\Windows\Microsoft.NET\Framework\v4.0.30319 (or whatever .net 4 framework version you have)
    • type aspnet_regiis.exe -i and press enter

Thats it

 

 

Posted in IIS, Umbraco | Tagged: , , | Leave a Comment »

Howto programmatically add, update and remove ConnectionStrings in Umbraco

Posted by trikks on July 13, 2011

I found that amazing no-one ever posted snippets to howto actually manipulate the web.config file when using Umbraco.

Anyway, lets keep it short.

Dont forget to import the businesslogic.dll into your project and reference it

using System;
using System.Configuration;
using umbraco; // from businesslogic.dll

 

Adding a connectionString in web.config

Note, you should either replace the Camelot.SharePointProvider with your preferred provider or add a parameter to the method to be able to modify this dynamically.

/// <summary>
/// Adds a new connectionString in web.config.
/// </summary>
/// <param name="name">Name the connection</param>
/// <param name="connString">The actual connectionstring. Read more at http://docs.bendsoft.com/camelot-net-connector/</param>
public static void AddConnection(string name, string connString)
{
    var webConfig = new ExeConfigurationFileMap { ExeConfigFilename = GlobalSettings.FullpathToRoot + "web.config" };
    var config = ConfigurationManager.OpenMappedExeConfiguration(webConfig, ConfigurationUserLevel.None);
    config.ConnectionStrings.ConnectionStrings.Add(new ConnectionStringSettings(name, connString, "Camelot.SharePointProvider"));
    config.Save();

    ConfigurationManager.RefreshSection("connectionStrings");
}

Updating a connectionString in web.config

Note, if the connectionString doesn’t exist this method will create it for you

/// <summary>
/// Update an existing connectionString, if it dosn't exist it will be created
/// </summary>
/// <param name="name">Name the connection</param>
/// <param name="connString">The actual connectionstring. Read more at http://docs.bendsoft.com/camelot-net-connector/</param>
public static void UpdateConnection(string name, string connString)
{
    var webConfig = new ExeConfigurationFileMap { ExeConfigFilename = GlobalSettings.FullpathToRoot + "web.config" };
    var config = ConfigurationManager.OpenMappedExeConfiguration(webConfig, ConfigurationUserLevel.None);
    var section = (ConnectionStringsSection)config.GetSection("connectionStrings");

    if (section.ConnectionStrings[name] != null)
    {
        // Update the connectionstring if it exist
        section.ConnectionStrings[name].ConnectionString = connString;
        config.Save();

        ConfigurationManager.RefreshSection("connectionStrings");
    }
    else
    {
        // ...otherwise we add a new
        AddConnection(name, connString);
    }
}

Delete a connectionString in web.config

/// <summary>
/// Remove a connectionString
/// </summary>
/// <param name="name">The name of the connectionString to remove</param>
public static void RemoveConnection(string name)
{
    var webConfig = new ExeConfigurationFileMap { ExeConfigFilename = GlobalSettings.FullpathToRoot + "web.config" };
    var config = ConfigurationManager.OpenMappedExeConfiguration(webConfig, ConfigurationUserLevel.None);
    var section = (ConnectionStringsSection)config.GetSection("connectionStrings");

    // Die if the connectionstring dosn't exist
    if (section.ConnectionStrings[name] == null) return;

    var keys = section.ConnectionStrings;
    keys.Remove(name);
    config.Save();
    ConfigurationManager.RefreshSection("connectionStrings");
}

Check if connectionstring exist

/// <summary>
/// Check if a connectionString with the same name already exist
/// </summary>
/// <param name="name">Name of the connection</param>
/// <returns>True on existence, otherwise false</returns>
private static bool ConnectionExist(string name)
{
    var webConfig = new ExeConfigurationFileMap { ExeConfigFilename = GlobalSettings.FullpathToRoot + "web.config" };
    var config = ConfigurationManager.OpenMappedExeConfiguration(webConfig, ConfigurationUserLevel.None);
    var section = (ConnectionStringsSection)config.GetSection("connectionStrings");

    // Return false if it doesn't exist, true if it does
    return section.ConnectionStrings[name] != null;
}

Thats it!

Posted in Umbraco | 1 Comment »

 
Follow

Get every new post delivered to your Inbox.