I try to get list from remote SharePoint server using CSOM in .NET Web Application, but ClientContext.ExecuteQuery()
return exception
Cannot contact site at the specified URL
If I try to get list from local server, all work fine. How do I fix it? Why an exception occurs?
I use following code:
public string testRest()
{
try
{
ClientContext context = new ClientContext(new Uri(@"http://sharepointRemoteServer/sites/subsite"));
context.AuthenticationMode = ClientAuthenticationMode.Default;
context.Credentials = CredentialCache.DefaultNetworkCredentials;
List spList = context.Web.Lists.GetByTitle("ListName");
context.Load(spList);
context.ExecuteQuery();
return "OK";
}
catch (Exception ex)
{
return ex.Message;
}
}