Copied to clipboard

Flag this post as spam?

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


  • Souvik 9 posts 89 karma points notactivated
    Sep 17, 2023 @ 07:10
    Souvik
    0

    Umbraco.Content() inside a Razor page

    Hi everyone, I am trying to access the Content() method of the UmbracoHelper class with the Umbraco property which is in the UmbracoViewPage like this Umbraco.Content() in a Razor view. But I am getting this error

    The type or namespace name 'Content' does not exist in the namespace Umbraco.

    I have also tried to inject the UmbracoViewPage directly in the razor page and using the method, that way I don't get any compilation errors but i get runtime error in Program.cs. While Injecting I am adding the following code in startup.cs

    services.AddTransient<UmbracoViewPage>();
    

    Still it is not able to resolve it. Is there any other way to call the Content() method in the Razor page or am I making a mistake somewhere? Thank you.

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 7x admin c-trib
    Sep 17, 2023 @ 19:12
    Chriztian Steinmeier
    0

    Hi Souvik,

    Something must have gone wrong in your view file - what does the first few lines look like? Does it inherit from UmbracoViewPage ?

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft