How to get page content in UmbracoApiController by umbracoUrlAlias
Hi, everyone.
I have a trouble to get page content when I use umbracoUrlAlias instead of normal url.
Actually below is good when I use normal url path.
IPublishedContent m = UmbracoContext.Content.GetByRoute(urlSegment);
But this is not working (m will be null) if I use umbracoUrlAlias.
In another hand, page is correctly displayed when I use both of normal and alias.
var urlAlias = item.Value<string>("umbracoUrlAlias");
Also, UmbracoContext.Current.ContentCache.GetByRoute(string url) could do, what you want.
(umbracoUrlAlias will not be in uppercase, all URL's in umbraco are lowercase check that)
How to get page content in UmbracoApiController by umbracoUrlAlias
Hi, everyone. I have a trouble to get page content when I use umbracoUrlAlias instead of normal url. Actually below is good when I use normal url path.
IPublishedContent m = UmbracoContext.Content.GetByRoute(urlSegment);
But this is not working (
m
will benull
) if I use umbracoUrlAlias.In another hand, page is correctly displayed when I use both of normal and alias.
How can I get page content by
Alias
?Hi Rail
The core Umbraco Content Finder 'ContentFinderByUrlAlias'
does it like this:
https://github.com/umbraco/Umbraco-CMS/blob/2bfef741914297c802bc6c77cc48780d7534f920/src/Umbraco.Web/Routing/ContentFinderByUrlAlias.cs#L54
essentially looping through all descendants of the site looking for an umbracoUrlAlias value that matches the alias being searched for.
Is that what you are after?
regards
Marc
Hello,
In order to get the umbracoUrlAlias value...
Also,
UmbracoContext.Current.ContentCache.GetByRoute(string url)
could do, what you want. (umbracoUrlAlias will not be in uppercase, all URL's in umbraco are lowercase check that)Hello, @AddWeb Solution Pvt.Ltd
In below line;
Can you access to
UmbracoContext.Current
? I can't seeCurrent
property inUmbracoContext
.is working on a reply...