How to update the properties of a website in the Sharepoint 2013 using CSOM

Steps
  • Open Visual Studio in your system.

  • Select Console Application template and give as name.

  • Add a Microsoft.Client Assembly reference file in right side reference tab in visual studio.

  • Replace Program.cs with the source code.
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5. using System.Threading.Tasks;  
  6. using Microsoft.SharePoint.Client;  
  7. namespace CSOMCodeSamples   
  8. {  
  9.     class Program   
  10.     {  
  11.         static void Main(string[] args)   
  12.         {  
  13.             // ClienContext - Get the context for the SharePoint Site    
  14.             ClientContext clientContext = new ClientContext("http://gauti.sharepoint.com/sites/sp/");  
  15.             // Get the SharePoint web    
  16.             Web web = clientContext.Web;  
  17.             // Update the web Title and Description properties    
  18.             web.Title = "Website Properties Updated";  
  19.             web.Description = "Updated the website  title using CSOM";  
  20.             web.Update();  
  21.             clientContext.Load(web);  
  22.             clientContext.ExecuteQuery();  
  23.             Console.WriteLine("Title:> " + web.Title + "; Description:> " + web.Description);  
  24.             Console.ReadLine();  
  25.         }  
  26.     }  
  27. }  
Output

Hit F5 and check the output.

Thanks for reading my blogs.