[英]Unable to connect to sharepoint site using Sharepoint Client Object Model
I'm attempting to write a console application to connect to one of our sharepoint application sites. 我试图编写一个控制台应用程序以连接到我们的SharePoint应用程序站点之一。 I'm running a basic example to ensure connectivity.
我正在运行一个基本示例以确保连接性。 The program keeps failing with the following error: The remote server returned an error: (500) Internal Server Error.
程序不断失败,并出现以下错误:远程服务器返回错误:(500)Internal Server Error。
Status: System.Net.WebExceptionStatus.ProtocolError 状态:System.Net.WebExceptionStatus.ProtocolError
I don't have access to the IIS server to check the logs. 我无权访问IIS服务器来检查日志。 My code is as follows:
我的代码如下:
string siteUrl = "http://spsiteurl/";
ClientContext clientContext = new ClientContext(siteUrl);
clientContext.AuthenticationMode = ClientAuthenticationMode.Default;
clientContext.Credentials = new NetworkCredential("...", "...", "...");
Web oWebsite = clientContext.Web;
clientContext.Load(oWebsite,
w => w.Title);
clientContext.ExecuteQuery();
Console.WriteLine(oWebsite.Title);
Any direction on where I could be going wrong? 关于我可能会出错的任何方向?
try below code 尝试下面的代码
ClientContext context = new ClientContext("https://test.com/");
System.Net.ServicePointManager.ServerCertificateValidationCallback =
((sender, certificate, chain, sslPolicyErrors) => true);
string strUserName = @"abc";
string strPassword = "pwd";
var credentials = new NetworkCredential(strUserName, strPassword);
Web web = context.Web;
context.Load(web, w => w.Title);
context.Credentials = credentials;
context.ExecuteQuery();
// Now, the web's properties are available and we could display
// web properties, such as title.
System.Console.WriteLine("Web Title");
System.Console.WriteLine(web.Title);
it will work fine in console 它将在控制台中正常工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.