csom-gettitle

Title: Get Site URL and Title using CSOM.


Step1:
Follow the http://sharepoint-lakku.blogspot.in/p/csom-setup.html steps.

Step2:

Add below configurations in app.config
  1. <appSettings>  
  2.     <add key="mysiteurl" value="https://office365.sharepoint.com/sites/lakku"/>  
  3.     <add key="myusername" value="sudip@hpeoffice365.onmicrosoft.com"/>  
  4.     <add key="mypassword" value="mypass@123"/>  
  5. </appSettings>  

Step3:

Add below reference.



Step4:
Add below name spaces in code



  • using System;  
  • using Microsoft.SharePoint.Client;  
  • using System.Configuration;  
  • using System.Security;  



  • Step5:
    Add below code



  • static void Main(string[] args)  
  •         {  
  •   
  •             string siteURL = ConfigurationManager.AppSettings["mysiteurl"];  
  •             string userName = ConfigurationManager.AppSettings["myusername"];  
  •             string password = ConfigurationManager.AppSettings["mypassword"];  
  •   
  •             using (var clientContext = new ClientContext(siteURL))  
  •             {      
  •                 SecureString securePassword = new SecureString();  
  •                 foreach (char c in password.ToCharArray()) securePassword.AppendChar(c);  
  •                 clientContext.Credentials = new SharePointOnlineCredentials(userName, securePassword);  
  •                 Web web = clientContext.Web;  
  •                 clientContext.Load(web);  
  •                 clientContext.ExecuteQuery();  
  •                 Console.WriteLine(web.Title + " , " + web.Url);  
  •                 Console.ReadKey();  
  •   
  •             }  
  •         }  


  • Out Put: