Copied to clipboard

Flag this post as spam?

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


  • Claus Marin Kaiser 1 post 71 karma points
    1 week ago
    Claus Marin Kaiser
    0

    Sudden Missing 'Home' type or namespace.

    I am trying to build my very first Umbraco project and everything worked great until I followed the "Member Registration and Login" tutorial from umbracos site.

    After adding the Login page under Content suddenly all my pages show the following error.

    The type or namespace name 'Home' could not be found (are you missing a using directive or an assembly reference?)

    This is appointed to the top of my Master template with the line var home = (Home)Model.Root();

    I have zero clue as to where to look for the bug or why this would happen, so if anyone can point me to the right direction it would be immensely appreciated

  • Marc Goodson 2155 posts 14386 karma points MVP 9x c-trib
    1 week ago
    Marc Goodson
    0

    Hi Claus

    Umbraco generates 'models' based on the Document Type of your schema to make it easy in your templates to write out the values of the properties in the Document Type.

    So if you have a Document Type called Home, it will generate a model also called 'Home' that will contain all the properties of the Home Document Type.

    Your line of code

    var home = (Home)Model.Root();
    

    says get me the content item at the root of this site and cast it to the type 'Home'

    and as this is in your layout template this code is being executed on every page,

    so what I think 'might have happened' in following the tutorial, is you have either renamed the 'Home' Document type or, as part of the tutorial there is something preventing Umbraco from generating all the models or you you've added the 'Login Page' directly under Content? - maybe now Model.Root() is the LoginPage and not the Home page but I think that would give a different error...

    Additionally depending on which 'modelsbuilder mode' you are running in: https://docs.umbraco.com/umbraco-cms/13.latest-lts/reference/templating/modelsbuilder/builder-modes you may need to rebuild your application to get the updated models.

    How to resolve this, depends a little on what you are using the 'home' variable for in the master template - but first thing would be to check that the Home document type is still called Home... and then make an update to your new Login Document type and have a look in the Umbraco logs to see if there has been an issue generating models generally...

    regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft