Sean Holmesby

.NET and Sitecore Developer

By

Safe Dependency Injection for MVC and WebApi within Sitecore

This post describes how we’ve considered approaching dependency injection with Sitecore at Hedgehog Development.
Many people have posted about dependency injection in Sitecore before, and each has had their own twist.

We’ve noticed that sometimes Sitecore controllers are failing to be resolved when there is a custom Dependency Resolver added.
The problem, as described in Mickey’s first post, is that MVC only allows for one DependencyResolver. So the moment you set your own Dependency Resolver, whatever was set there before (like whatever Sitecore set as the Dependency Resolver) will no longer work.
Because of this, Sitecore’s registered types will no longer get resolved, and you might see the following errors in the logs when you try to access one of the out-of-the-box Sitecore applications.

Exception: Sitecore.Mvc.Diagnostics.ControllerCreationException
Message: Could not create controller: 'Settings'.
The current route url is: 'api/sitecore/{controller}/{action}'. 
Source: Sitecore.Mvc
   at Sitecore.Mvc.Controllers.SitecoreControllerFactory.CreateController(RequestContext requestContext, String controllerName)

Message: No component for supporting the service Sitecore.Controllers.SettingsController was found

I spoke to Charlie Turano about this, and our solution was to create a ChainedMvcResolver, which will set a ‘Fallback Resolver’ to whatever the resolver was before we came along and set ours.
Read More

By

Fixing Visual Studio IntelliSense in Sitecore MVC Views

IntelliSense in Visual Studio is a fantastic auto-complete feature that greatly improves your Sitecore development, however I’ve occasionally seen this not working in my MVC solutions.

01 - HTML Sitecore Helper not working

In particular, I was seeing the following error highlighted around any calls to the @Html.Sitecore() helper:-

‘System.Web.Mvc.HtmlHelper<Model>’ does not contain a definition for ‘Sitecore’ and no extension method ‘Sitecore’ accepting first argument of type ‘System.Web.Mvc.HtmlHelper<Model> could be found.’

This would mean that I could not get auto-complete on the @Html.Sitecore() helper, nor would I get auto-complete for my properties on my Glass Models.

Read More

By

Sitecore MVC: Page Editor friendly Views with Glass Mapper

I originally published this post on the Igloo blog.

Last week Mike Edwards, the creator of Sitecore Glass Mapper, presented version 3 of the new Glass Mapper on the Sitecore Virtual User Group. [Slides here], [Video here]

During the webinar I asked if it was possible to use Glass models in MVC Views, while still having them Page Editor friendly.
After the webinar, Mike held a Google Hangout, and some other developers expressed their interest in how this could be done with Sitecore MVC.

This blog post details how the developers at Igloo enable the page editor using Glass Mapper with Sitecore MVC.

Read More