Sitecore 8 dialogs not working?

Recently I’ve seen Sitecore fail to load the JavaScript files for Speak and so break using the Sitecore desktop by failing to load dialogs in the content editor and in the control panel. This can happen in a couple of ways and the reasons behind it are pretty subtle. The issue I found for this post was that the SPEAK javascript files were not loading.

The SPEAK system relies on a set of config files in the App_Config/Include folder and client libraries inside the sitecore/shell folder. To ensure that the configuration is loaded correctly and the JavaScript files are returned, you need to check:

  1. ‘/App_Config/Include/.Sitecore.Speak.Important.Config’ – make sure this doesn’t have the hidden attribute set. If you need to, remove the ‘.’ prefix to force a refresh
  2. Double check that all the client assets also don’t have the hidden attribute set.

To test that everything is ok, visit the following URL: <Your_Host>/-/speak/v1/assets/main-1.2.js

You should see the require.js calls setup and loading the libraries necessary for the Sitecore desktop. In another post I’ll cover how you can turn on minification and etags!

Hope this saves you some time!


Sitecore WebAPI – Hooking into the route setup

Setting up routes in MVC and WebAPI is pretty straightforward in Sitecore provided that its done in the correct pipeline. When I first started attempting to add routes, I quickly discovered that doing this via the Global ASAX wasn’t reliable. The reason for this is that the routes are setup in the initialise pipeline.

Fortunately Sitecore has this process mapped out in the the config file so all I needed to do is swap out the DefaultRouteMapper that comes out of the box. Lets look at the entry in Sitecore:

<setting name="Sitecore.Services.RouteMapper" value="NAMESPACE.CustomRouteMapper, ASSEMBLY_NAME" />

Continue reading

Sitecore WebAPI – Setting up IOC

I’ve had the opportunity to tinker in the depths of the WebAPI in Sitecore 7.5 and 8 recently. I’ll put up a post about setting up controllers easily shortly but until then I thought I’d share how to setup IOC.

In a normal WebAPI environment, we can create our resolver and attach it to the GlobalConfiguration. However, we must remember that Sitecore uses its own pipelines for MVC and WebAPI and so setting this up in the Global ASAX won’t work.

The way I’ve done it is to change the registered WebAPI initialiser class in the Sitecore.Services.Config file found in App_Config/Include. This lets me hook directly into the entry point for Sitecore related WebAPI and adjust the configuration accordingly.

Continue reading

Thoughts from an opinionated developer: API design, mocking and sitecore

A few thoughts for the weekend in my usual opinionated way. Please take these with a measure of whimsy!

Lets kick things off and poke about with the topic of API design. Now if we’re fair this topic has been done to death. That said, any topic like this is well worth re-visiting too. In any form of programming, there are always going to be best practises but our application of these should always be on a ‘well it depends’ nature.

We see this quite often in how an API is designed. Good practise tells us that it should be SOLID but the steps to achieving that in the confines of your
project can vary quite a bit. Its here that rigid adherence to ‘best practise’ without allocating a good helping of common sense and experience can stunt or even ruin an API for general use.

Continue reading

Sitecore 8 upgrade – check your .NET version

One of my current clients is making the transition to Sitecore 8. This went reasonably well as we decided to do a fresh installation rather than follow the upgrade path and then copy any content in manually.

What we weren’t prepared for was a number of errors using Sql Server and IIS. Specifically we were getting heap exceptions with and ntdll.dll. However, what was funny was that these errors weren’t occuring on everyones systems. In fact the only repeatable thing was sporadic database issues with connectivity.

After some investigation we found that we were on .NET 4.5.1 and this has some known issues. So if you’re getting issues with IIS, the worker process or with the dlls then this is one thing to look into.

Needless to say we did a test installation on a working system (well one with the least amount of issues) and this ran ok. Then we rolled it out to the other systems and this fixed our system. You can find out more about the list of known issues on the Microsoft support site.

The .Net 4.5.2 update is a web installer so you’ll need Internet access for any machine you’re updating.


Production considerations – Mongo and xDB part four

There’s a massive amount of information regarding Mongo in production. The topic can get quite complex in a short space of time too, so I’ve attempted to distil some of it down into a manageable chunk. Whenever we think of moving to production we think of user security, network security, capacity or resource usage and allowing the system to scale. There are other topics too but this is a good place to start as the rest can be specific to each environment you’re working in.

Continue reading

Sitecore and Solr – Installation errors on Sitecore 7.5

Today I’ve been setting up Sitecore and Solr using the instructions found on the SDN. When generating the schema file, you might get an error like the following:

unknown field ‘_uniqueid’

This is when you load the core admin screen to check that the default core ‘itembuckets’ has been loaded correctly.  If you read the comments in the generated file it
will tell you that this value should be set to ‘id’. Like so:


I’ve not done any Solr setup in quite a while so I’m still testing the installation. Hopefully this is correct and will save someone some time!

What I want from Sitecore for Christmas – Thoughts from an opinionated developer

Perhaps contentious perhaps not but as an API I’d like to see a little consistency in the dependencies in Sitecore. Specifically when you look at the various Sitecore modules shipped by them we have Ninject, Unity, SimpleInjector and so on. As hard as it might be to have a specific team move away from their chosen favourite library, for large scale installations we as customers need some consistency in the libraries we use and support in our installations.

I do accept that these modules are supposed to be ‘black box’ but they all end up in the same bin folder and so we as customers have to manage the dependencies. I’m currently working in a Unity shop and so have had to manage the installation of the ECM (which uses Unity 2.x) while we are using 3.5. That’s not so bad but we have these other containers floating around in there too.

So for Christmas I’d like to see a consistent choice in IOC. Or a standardised container interface I can use to inject my own container when using Sitecore modules from other vendors.

Back to Basics: Sitecore validation – part 1

This is the first post in a series about back to basics. All to often I come across Sitecore projects that commit a number of sins. Hopefully this will tie together with the continuing series on working with the Sitecore platform instead of against it. So with that in mind, the first few parts will be about field validation in Sitecore.

Field validation is often overlooked. I think in part because the template editor has a quick and dirty interface for setting all the common properties such as name, source, shared etc. But to setup the validation, help text and the like you have to go into the field itself.

However, the content editors experience can be greatly enhanced with good validation with clear, concise error messages. It also means that as developers, we can enforce a little safety in our environment and increase our chances that our code will get data in the right ‘shape’.

A short history lesson

Before Sitecore 5, validation was done with regular expressions and a generic error message. This would fire and the user would see a popup with that message. After a while this would get pretty annoying as the editor couldn’t really see which fields were invalid and, in some cases, the warning wasn’t a critical error. Inevitably, unless all of the fields were required and the error messages could be made verbose enough, validation was turned off.

Even now Sitecore 7.x supports this functionality but using it is an incredibly bad idea.

Sitecore validation done right

Validation done right means you need to use the validators built into Sitecore (or add your own) using the various multi-lists directly on the field item for your template. If you do so, you have the advantage that as the editor builds their content, they get visual cues as to which field is incorrect. This appears as a red bar next to the field and colour spots to the top right (in the content editor). You also have the advantage that you can set the levels of these errors and class some as critical meaning the user can’t progress without fixing and you can make others ‘a bad idea’.

More importantly, these are all written in .NET code. What this means is that when you write your own, you’ll be able to unit test them under various conditions and more easily have them as part of your continuous integration builds.

In summary

This post was particularly short as an introduction to validators but they are more of a ‘show me the code’ topic. Its also pretty near to Christmas and I have small people to entertain! 🙂

In my next post on this topic, I’ll look at writing a very simple validator, registering it with Sitecore and setting its error level. More importantly, we’ll look at making it have different options per language and so handle some interesting scenarios. We’ll also have a unit test setup for it and I’ll put it on Github for reference.


Making backups and importing data – Mongo and xDB part three

There are a few ways you can make a backup with Mongo. The most simple is to take a copy of the database files and put them somewhere safe. This is made easier if you’ve put each database into its own directory. However, this is a pretty naive method as you will have to stop the server and restart it. You also will be taking a full backup. That said, this method does have its uses in a scenario where you are messing around with a secondary but that’s beyond the scope of this short post.

Its possible to extend this a little by using mongodump against the file system. The tool will lock the files so the database cannot be in use at the time but it at least provides a binary export of the data.

For a developer scenario, its more likely that we’ll be using mongodump, mongorestore, mongoimport and mongoexport against our running database. We may need some data from a co-worker or from the live system or we may be the provider of some data to another member of our team.

Continue reading