在设置代理的环境下使用SharePoint CSOM

SharePoint 的CSOM都是通过HttpRequest来实现和SharePoint服务器的交互的,那么我们如何设置HttpWebRequest的一些特性呢,如Cookie,WebProxy?

static void Main(string[] args)
{
System.Net.ServicePointManager.ServerCertificateValidationCallback = (object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) => true;
ClientContext context = new ClientContext(https://domain.sharepoint.com); SecureString se = new SecureString();
foreach (var cc in "password")
{
se.AppendChar(cc);
} context.Credentials = new SharePointOnlineCredentials("user@domain.onmicrosoft.com", se); context.ExecutingWebRequest += context_ExecutingWebRequest; context.ExecuteQuery(); } static void context_ExecutingWebRequest(object sender, WebRequestEventArgs e)
{
//e.WebRequestExecutor.WebRequest.Proxy = new System.Net.WebProxy("");
//e.WebRequestExecutor.WebRequest.CookieContainer= cookie
}

  通过ExecutingWebRequest 这个事件来定义httpWebRequest的一些行为

上一篇:如何查看安装的java是32位的,还是64位的


下一篇:Dictionary读取键值的快捷方法