Get site root in ViewComponent called from a Block
# help-with-umbraco


10/12/2023, 1:35 PM
HOpefully a quick one. How to get the site root on a multi-tenant site, in a ViewComponent called from a Block/partial. var site = content.Root(); works when the ViewComponent is called from a page View but not when called from a partial. Have tried content.Parent.Root() but no joy.
Have also tried variations on a theme with _umbracoContextAccessor but not working, not sure how exactly to do it
IPublishedContent siteRoot = _umbracoHelper.ContentAtRoot().FirstOrDefault(); - got it
Actually what I actually need is the homepage node of the site I'm on. Still struggling - am sure it should not be this difficult, probably missing something really basic. I have tried all sorts of versions of umbracoContext, umbracoHelper etd
think I might have it - @await Component.InvokeAsync("SitemapDownloads", Model.BaseModel); rather than just Model.