我正在编写一个使用客户端对象模型访问SharePoint网站的应用程序,但我在代理服务器后面。
我调用...
我调用...
ClientContext.ExecuteQuery()
当您遇到以下错误信息时...
远程服务器返回了一个错误:(407)需要代理身份验证。
如何将代理凭据传递给客户端上下文对象...?
ClientContext.ExecuteQuery()
当您遇到以下错误信息时...
远程服务器返回了一个错误:(407)需要代理身份验证。
如何将代理凭据传递给客户端上下文对象...?
ClientContext context = new ClientContext("<a valid url>");
context.ExecutingWebRequest += (sen, args) =>
{
WebProxy myProxy = new WebProxy();
myProxy.Address = new Uri("http://<proxy_server_address>");
myProxy.Credentials = new System.Net.NetworkCredential("jack_reacher","<password>", "<domain>");
args.WebRequestExecutor.WebRequest.Proxy = myProxy;
};
context.ExecuteQuery();
编辑:修复了打字错误(ags --> args)
我认为你需要在<configuration>
节点内的app.config中添加以下内容:
<system.net>
<defaultProxy useDefaultCredentials="true" >
</defaultProxy>
</system.net>
<system.net>
<defaultProxy>
<proxy
usesystemdefault="False"
proxyaddress="http://myproxyserver.company.com:8080"
bypassonlocal="True"
/>
</defaultProxy>
</system.net>