Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Qaisar 21 posts 41 karma points
    3 days ago

    Umbraco headrest V8

    I am trying to implement Umbraco headrest project from Matt Brailsford. I have cloned the project from github and followed the instructions for setting it up for the Umbraco v8. I setup default umbraco starter kit and tried the basic setup for headrest with mapping from Home node to HomePageViewmodel as in

    I am getting an error : InvalidOperationException: Don't know how to map Umbraco.Web.PublishedModels.Home to test.headrestv8.HomePageViewModel.

    Here is the code for Configuration component is:

    public class HeadRestConfigComponent : IComponent
        private readonly HeadRest _headRest;
        public HeadRestConfigComponent(HeadRest headRest)
            => _headRest = headRest;
        public void Initialize()
            _headRest.ConfigureEndpoint(new HeadRestOptions
                ViewModelMappings = new HeadRestViewModelMap()
        public void Terminate() { }
    public class HeadRestConfigComposer : ComponentComposer<HeadRestConfigComponent>
    { }

    Right now i am only trying to map one field. The code for MapDefinition is:

    public class TestHeadRestMapDefinition : IMapDefinition
        public void DefineMaps(UmbracoMapper mapper)
            mapper.Define<Home, HomePageViewModel>(
                (source, context) => new HomePageViewModel(),      // Constructor function
        private void Map(Home source, HomePageViewModel target, MapperContext context)
            target.ColorTheme = source.ColorTheme;
    public class TestHeadRestMapDefinisionComposer : IUserComposer
        public void Compose(Composition composition)

    The code ViewModel is:

    public class HomePageViewModel
        public string ColorTheme { get; set; }

    I can't figure out whats going wrong or did i set it up in a wrong way? Any help would be really appreciated.

Please Sign in or register to post replies

Write your reply to: