How to differentiate between different type of site pages?

Yuvraj Patil 361 Reputation points
2022-09-12T15:44:59.14+00:00

Hello,

I have a requirement where I need to differentiate between site page, wiki page, web part page and repost page in CSOM. could you please help me with any property or value or anything using which I can differentiate them?

Thanks in advance!

@RaytheonXie_MSFT

SharePoint Server
SharePoint Server
A family of Microsoft on-premises document management and storage systems.
2,214 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,599 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,663 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,572 questions
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 30,991 Reputation points Microsoft Vendor
    2022-09-14T03:02:17.677+00:00

    Hi @Yuvraj Patil
    As far as I know, there is no such property to distingush site page, wiki page, web part page. Per my test, the content type of web part page is Document and which in site page and wiki page is Site Page. And in wiki page, field CanvasContent1 must be null. So we can determine wiki page and site page by CanvasContent1
    240818-image.png
    240766-image.png
    240834-image.png
    240805-image.png
    Please refer to following code

    ListItem item = ctx.Web.Lists.GetByTitle("Site Pages").GetItemById(97);  
    ctx.Load(item);  
    ctx.Load(item.ContentType);  
    ctx.ExecuteQuery();  
    if ("Document" == item.ContentType.Name) {  
        Console.WriteLine("web part page");  
    }  
    else if ("" != item["CanvasContent1"] && null != item["CanvasContent1"]) {  
        Console.WriteLine("Site page");  
    }  
    else {  
        Console.WriteLine("Wiki page");  
    }  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



0 additional answers

Sort by: Most helpful