我尝试从控制台实现内部部署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
提前致谢!