vendredi 27 février 2015

PublishingWeb.GetPublishingWeb is not working in SharePoint 2013, CSOM




var pWeb = PublishingWeb.GetPublishingWeb(context, context.Web);
context.Load(pWeb);
if (pWeb != null)
{
<This condition is true for Team and Publishing Site Both>
}


This code is not working, it's going in if condition, if we provide Team site context as well..



using (var clientContext = new ClientContext(webUrl))
{


var pWeb = PublishingWeb.GetPublishingWeb(clientContext, clientContext.Web);

clientContext.Load(pWeb);

if (pWeb != null)
{
Console.WriteLine("Web : " + webUrl + " is a publishing web");

}
else
{
Console.WriteLine("Web : " + webUrl + "is not a publishing web");
}
}


I have already included - Microsoft.SharePoint.Client.Publishing .. REFERENCE AND NAMESPACE in my project


I am using SharePoint 2013. Kindly suggest what is the issue here? why it's going in if condition for team site.








0 commentaires:

Enregistrer un commentaire