从控制台C#连接Intranet(OnPremise)SharePoint Server 2013

时间:2018-06-14 08:02:40

标签: c# sharepoint sharepoint-2013 intranet

我尝试从控制台实现内部部署SharePoint连接,如下文所述, https://sharepoint.stackexchange.com/questions/205515/first-time-connecting-to-sharepoint-server-2013-from-console/205529?newreg=95ed260c717c4d9fb5fe4856a2daf71a

但事实是,当执行程序时,它会抛出内部异常(代码:500)。无法连接服务器: - (

请检查下面的代码,让我知道我在哪里/做错了什么。

using (var clientContext = new ClientContext("http://customersupport/"))
        {
            try
            {
                Console.WriteLine("connecting on-premise sharepoint....");

                clientContext.Credentials = new NetworkCredential(@"domain\username", "password");

                // Get the SharePoint web  
                Web web = clientContext.Web;

                // Load the Web properties  
                clientContext.Load(web);

                // Execute the query to the server.  
                clientContext.ExecuteQuery();

                Console.WriteLine("Conneciton done successfully");

            }
            catch (Exception exe)
            {
                //throws internal exception
                Console.WriteLine(exe.Message);
            }
        }

下面是完整的错误消息:

System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
   at System.Net.HttpWebRequest.GetResponse()
   at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
   at Microsoft.SharePoint.Client.ClientContext.GetFormDigestInfoPrivate()
   at Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest()
   at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
   at ConnectSharepoint.SharePointOnPremise.Main(String[] args) in C:\Kishor\ac\2018\Test\ConnectSharepoint\SharePointOnPremise.cs:line 34

提前致谢!

1 个答案:

答案 0 :(得分:0)

检查以下内容:

1.检查所有应用池,并检查" SharePoint Web服务根"停了。

enter image description here

2.检查这些SharePoint服务。

enter image description here

3.检查IIS管理服务。

enter image description here