Sharepoint Client Object Model Check SharePoint Site Availability

To check SharePoint Site is available or not using client object model use below code .

#region “Validatre Sharepoint Site”
private bool ValidateSPSite(string SharepointSite)
{
using (ClientContext clientContext = new ClientContext(SharepointSite))
{
try
{
clientContext.Credentials = System.Net.CredentialCache.DefaultCredentials;

Microsoft.SharePoint.Client.Web web = clientContext.Web;

Microsoft.SharePoint.Client.Web site = clientContext.Web;

clientContext.Load(site);

clientContext.ExecuteQuery();

return true;
}
catch (Exception)
{
return false;

throw;
}
}
}
#endregion

Parameter SharepointSite is the name of Sharepoint Site which we want to check that if it is exist or not.

 

 

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s