Category Archives: Umbraco

How to recover from “Object reference not set to an instance of an object” error blocking access to Umbraco control panel

I shocked when I found that I couldn’t access Umbraco control panel of one of the most important websites that my client has. It threw “Object reference not set to an instance of an object” error once I successfully logged in to the control panel.

image

After making backup and small research I found a way to recover from that annoying thing. The workaround was recycling the Application Pool that the website use.

Umbraco: How to get Media in code-behind

To get a media (i.e.: image)  in code-behind you can do it like this.

var currentPage = umbraco.presentation.nodeFactory.Node.GetCurrent();
var media = new umbraco.cms.businesslogic.media.Media(
            Convert.ToInt32(currentPage.GetProperty("[property]").Value)
    );
string imageUrl = media.getProperty("umbracoFile").Value.ToString();