Home > Back-end >  Show Intellisense in Umbraco Controller 9
Show Intellisense in Umbraco Controller 9

Time:07-15

What I would like to do is to access all of the properties of the rootContent with Intellisense. I get these backoffice objects (generated with modelsbuilder) via Umbraco.Helper.ContentAtRoot(); method, but the only way to see the backoffice properties is while debugging. Thanks for all the help!

public class SearchResultController : RenderController
{
    private readonly UmbracoHelper UmbracoHelper;
    private readonly IPublishedValueFallback PublishedValueFallback;
    //private readonly SearchRepository SearchRepository;

    public SearchResultController(ILogger<ContentPageController> logger, ICompositeViewEngine compositeViewEngine, IUmbracoContextAccessor umbracoContextAccessor,
        IPublishedValueFallback publishedValueFallback,
        UmbracoHelper umbracoHelper
        /*,SearchRepository searchRepository*/)
        : base(logger, compositeViewEngine, umbracoContextAccessor)
    {
        UmbracoHelper = umbracoHelper;
        PublishedValueFallback = publishedValueFallback;
        //SearchRepository = searchRepository;
    }

    public override IActionResult Index()
    {     
        var rootContent = UmbracoHelper.ContentAtRoot().SingleOrDefault();
        var children = rootContent.ChildrenForAllCultures.ToList();
        return View("~/Views/SearchResult.cshtml", contentPage);
    }
}

CodePudding user response:

If your generated ModelsBuilder files are part of your project, you should be able to cast the rootContent:

var rootContent = UmbracoHelper.ContentAtRoot().FirstOrDefault() as WhateverClassYourRootNodeIs;

That should get you Intellisense. Is that what you mean?

  • Related