I googled and found one of the easy way to get the PageLayoutName.
if (PublishingWeb.IsPublishingWeb(web)) { PublishingWeb publishingWeb = PublishingWeb.GetPublishingWeb(web); PublishingPageCollection publishingPages = publishingWeb.GetPublishingPages(); PublishingPage publishPage = null; var spfile = SPContext.Current.File; Guid id = spfile.UniqueId; if (publishingPages[id] != null) { publishPage = PublishingPage.GetPublishingPage(publishingPages[id].ListItem); currentPageLayout = publishPage.Layout.Name; if (currentPageLayout.EndsWith(".aspx")) { currentPageLayout = currentPageLayout.Substring(0, currentPageLayout.Length - 5); } } }
The above code is having a heavy performance issue as I am getting all the PublishingPages and searching is in Pages.
One of the already ways is to use CAML Query in