Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Cannot contact site at the specified URL on try ClientContext.ExecuteQuery();

$
0
0

Hello!

I try 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 get list from local server all work fine. How fix it? Why an exception occurs?

I use follow 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;
            }
        }


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>