get "DocumentID" in controller from NodeAlias?

Muhammad Kaleem asked on March 1, 2019 17:50

i have NodeAlias of a page how can i get "DocumentID" in controller from that NodeAlias?

Recent Answers


Brenden Kehren answered on March 1, 2019 17:56

Check out the API Examples.

You can also use something like this:

var document = DocumentHelper.GetDocuments().WhereEquals("NodeAlias", nodeAlias).FirstObject;

int docId = document.DocumentID;

Keep in mind, the NodeAlias field is NOT a unique value field. So you could get multiple records being returned.

1 votesVote for this answer Mark as a Correct answer

Muhammad Kaleem answered on March 1, 2019 18:07 (last edited on March 1, 2019 18:08)

thanks brenden, but i want to get current page DcumentID to register page builder in my controller action.

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on March 1, 2019 19:31

Something like this?

public ActionResult Index(string pageAlias)
{
    var landingPage = LandingPageProvider.GetLandingPage(pageAlias, "EN-US", "sitename").FirstObject;
    if (landingPage == null)
    {
        return HttpNotFound();
    }

    HttpContext.Kentico().PageBuilder().Initialize(landingPage.DocumentID);

    return View();
}
1 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.