我正在编写一个使用客户端对象模型访问 SharePoint 网站的应用程序,并且我位于代理服务器后面。
我打电话...
ClientContext.ExecuteQuery()
并收到以下错误消息...
远程服务器返回错误:(407) 需要代理身份验证。
如何将我的代理凭据传递给客户端上下文对象...?
您需要将 WebProxy (System.Net.WebProxy) 对象传递给执行查询的 WebRequest 实例。这样做的一种方法是
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)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)