Copied to clipboard

Flag this post as spam?

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

  • Greg Fyans 140 posts 342 karma points
    Sep 16, 2014 @ 13:28
    Greg Fyans

    Strongly typed views and mixins


    Using 7.1.6, uSiteBuilder 2.0.1.

    I have 2 views:

    • _MasterLayout.cshtml
    • Homepage.cshtml

    2 doctypes:

    • Hompage
    • Meta

    Meta contains thing like page title, meta description etc.

    Homepage is being told to pull in navigation properties using the mixins attribute:

            Name = "Homepage",
            AllowedTemplates = new[] { "Homepage" },
            DefaultTemplate = "Homepage",
            IconUrl = "icon-home",
            Mixins = new[] { typeof(Mixins.Meta) })]
        public class Homepage : DocumentTypeBase
            // homepage properties

    The import works fine and I can create a new homepage node and access the meta properties.

    I have set up my templates like so:

    • _MasterLayout.cshtml inherits from Vega.USiteBuilder.UmbracoTemplatePageBase
    • Homepage.cshtml inherits from Vega.USiteBuilder.UmbracoTemplatePageBase<DocTypes.Pages.Homepage>

    I can access the homepage doctype properties just fine, but I have no idea how to access the mixin properties. Using the following:


    Gives me the following error:

    'Castle.Proxies.HomepageProxy' does not contain a definition for 'Content'

    Changing my master layout to inherit from Umbraco.Web.Mvc.UmbracoViewPage<dynamic> yields the same error.

    Is there no way to access a properties collection within a strongly typed view?


  • Greg Fyans 140 posts 342 karma points
    Nov 28, 2014 @ 13:17
    Greg Fyans

    Unrelated to the above but worth knowing if you ever receive an error like this:

    The model item passed into the dictionary is of type 'Castle.Proxies.HomepageProxy', but this dictionary requires a model item of type 'Umbraco.Web.Models.RenderModel'.

    It looks like this is related to uSiteBuilder's default behaviour of setting an Umbraco default MVC controller. This requires all template aliases to match the doctype alias. I'm not sure why this is the default behaviour, but if you want to disable it, add this your appSettings:

    <add key="siteBuilderEnableDefaultControllerType" value="false" />
  • Greg Fyans 140 posts 342 karma points
    Nov 28, 2014 @ 13:21
    Greg Fyans

    FYI, there's no current way of accessing properties from mixins, but I'm hoping that once 7.2 comes out we can change the code from using attributes (evil) to using class inheritence (good) and having the default behaviour of uSiteBuilder create doctypes with compositions rather than inherited doctypes.

    That way we'll have easy to use doctypes in Umbraco with compositions, and access to the properties via intellisense in VS.

Please Sign in or register to post replies

Write your reply to: