Programmatically set - Allow items to appear in search results?
The following sample code helps you to setup the following setting through CSOM.
Allow items from this document library to appear in search results?
using (ClientContext SourceSiteClientContext = new ClientContext(SourceSite))
{
Web SourceWeb = SourceSiteClientContext.Web;
SourceSiteClientContext.Credentials = new NetworkCredential(SourceSiteUserName, SourceSitePassword, SourceSiteDomain);
WriteStatus("Successful..", false);
ListCollection collList = SourceWeb.Lists;
SourceSiteClientContext.Load(collList);
SourceSiteClientContext.ExecuteQuery();
foreach (List oList in collList)
{
if (oList.Title == "Pages")
{
Console.WriteLine(oList.Title);
oList.NoCrawl = true;
oList.Update();
SourceSiteClientContext.ExecuteQuery();
}
}
}
0 comments