Copied to clipboard

Flag this post as spam?

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


  • Chris Dennett 5 posts 75 karma points
    15 days ago
    Chris Dennett
    0

    does not contain a definition for and no accessible extension method...

    I have the following code in the Footer.cshtml of my site:

    <li><span class="fa-solid fa-phone"></span><a href="tel:@primaryFooter.Phone">@primaryFooter.Phone</a></li>
    <li><span class="fa-solid fa-house"></span>@primaryFooter.Address</li>
    

    These two lines work perfectly. I was even able to track down the properties in the Primary Footer object, as seen here: enter image description here

    So I tried to add an additional property called "Fax" to the Primary Footer, like so: enter image description here

    I then tried to access this property in Footer.cshtml, but I am getting this error:

    'PrimaryFooter' does not contain a definition for 'Fax' and no accessible extension method 'Fax' accepting a first argument of type 'PrimaryFooter' could be found (are you missing a using directive or an assembly reference?)

    Here is the code as it is now:

    <li><span class="fa-solid fa-phone"></span><a href="tel:@primaryFooter.Phone">@primaryFooter.Phone</a></li>
    <li><span class="fa-solid fa-fax"></span>@primaryFooter.Fax</li>
    <li><span class="fa-solid fa-house"></span>@primaryFooter.Address</li>
    

    Why do "Address" and "Phone" work and my newly added "Fax" property doesn't? I really don't see how I could be missing a "using" or "include", since the "Address" and "Phone" properties are also part of the Primary Footer. What am I missing here?

  • Nik 1625 posts 7295 karma points MVP 7x c-trib
    15 days ago
    Nik
    0

    Hi Chris,

    It's a bit hard to know for sure, but I'm assuming you've made that change solely via the Umbraco back office?

    Based on the error you are reporting, my guess would be that the Umbraco Models for the document types haven't regenerated, and as such, aren't available at run time.

    Now the next bit all depends on how your site has been built and what "mode" Umbraco's Models Builder is in.

    In theory, if your site is running in PureLive/InMemoryAuto mode, then the models would have automatically regenerated and you wouldn't be having this issue. So my guess is that the original developers of the site (if it wasn't you) have set them up to generate files to disk and then be compiled during build/runtime (depending on what version of Umbraco this is).

    Could you confirm what version of Umbraco you are running? And if you have access to the original source code of your website and not just the deployed version?

    Thanks

    Nik

  • Chris Dennett 5 posts 75 karma points
    15 days ago
    Chris Dennett
    0

    Hi Nik! Thanks so much for the reply!

    Firstly, you are correct that we hired a contractor to deliver us the site, but thankfully we do have access to the source code. We are running 13.5.2 (just updated from 13.3).

    You are also correct that I did make the change solely via the back office. However, I did take a look at the .Core.Models.Generated file for the "PrimaryFooter" object and can see the "Phone" and "Address" properties in the file, and do not see my newly created "Fax" property. I can see how one might simply define this property in that file, but I didn't try that as generated files can often be overwritten.

    Thank you so much and I hope this helps you help me! :)

Please Sign in or register to post replies

Write your reply to:

Draft