I am very new to Umbraco and trying to fix an issue where the TypedContentAtRoot() is returning null. Here is the code I am using to retrieve the homeNode of the current page.
I have to get the URL of a child page that the user has to be redirected to after clicking a button. The child page has been added to the parent page as a descendant and I have confirmed the same.
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
var homeNode = umbracoHelper.TypedContentAtRoot().Where(w =>
w.ContentType.Alias.Equals("HomePage"));
var descendants =homeNode.DescendantsOrSelf("SubmittedPage");
var confirmationPage = descendants.FirstOrDefault();
return confirmationPage?.Url;
To also verify this, I performed a check where I can get the current PageID and that is also being returned as null
var currentPageId = UmbracoContext.Current.PageId;
Basically I have a main HomePage as a document type. It has various child pages that I have verified exists. There is some jQuery validation that sends a get Request to retrieve the confirmationPage Url as shown in the code below.
Need to get URL of child node in Umbraco
Hi,
I am very new to Umbraco and trying to fix an issue where the TypedContentAtRoot() is returning null. Here is the code I am using to retrieve the homeNode of the current page.
I have to get the URL of a child page that the user has to be redirected to after clicking a button. The child page has been added to the parent page as a descendant and I have confirmed the same.
To also verify this, I performed a check where I can get the current PageID and that is also being returned as null
Basically I have a main HomePage as a document type. It has various child pages that I have verified exists. There is some jQuery validation that sends a get Request to retrieve the confirmationPage Url as shown in the code below.
Hi Suhasini
When querying like you are you need to use the Document Type Alias.
So, wonderin if you have confirmed the Homepage has a document type alias of "HomePage" (capital H) ?
Typically document types aliases are camel case and so might be a lower case "h".
Cheers
Nigel
Yes, I just rewrote the word "HomePage" before posting the code on a forum. But it was upper camelcase and I reconfirmed it.
However I also found a solution to the problem.
I had to create the Content-Type of the page I was looking for. Since the content-type of the page wasnt created the result was returning null.
is working on a reply...