Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi, there is a way in a partial view to retrieve a content by URL?
In v8 we could use umbracoContext.Content.GetByRoute(url); but I didn't find an equivalent method in v11.4
umbracoContext.Content.GetByRoute(url);
Can anyone help me?
Thank you
Adriano
Founded.
I need to injet the UmbracoContextAccessor
@inject IUmbracoContextAccessor UmbracoContextAccessor
and use the UmbracoContextAccessorExtension to get the Umbraco Context and to use its methods
var test = UmbracoContextAccessorExtensions.GetRequiredUmbracoContext(UmbracoContextAccessor)?.Content?.GetByRoute(megaNavItem.Url);
Hope that this can help anyone
I think you can also access the UmbracoContext directly, like this:
var test = this.UmbracoContext.Content.GetByRoute(megaNavItem.Url);
I tried but received these errors:
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Umbraco 11 - How to retrieve an IPublishedContent by URL in a Partial View?
Hi, there is a way in a partial view to retrieve a content by URL?
In v8 we could use
umbracoContext.Content.GetByRoute(url);
but I didn't find an equivalent method in v11.4Can anyone help me?
Thank you
Adriano
Founded.
I need to injet the UmbracoContextAccessor
and use the UmbracoContextAccessorExtension to get the Umbraco Context and to use its methods
Hope that this can help anyone
Adriano
I think you can also access the UmbracoContext directly, like this:
I tried but received these errors:
is working on a reply...