我正在尝试使用HttpWebRequest
从SharePoint文档库中读取文件。为此,我必须传递一些凭证。我正在使用以下请求:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "GET";
request.ContentType = "application/msexcel";
request.UserAgent = "Mozilla/4.0+(compatible;+MSIE+5.01;+Windows+NT+5.0";
request.Credentials = new NetworkCredential(UserName, PassWord);
这是通过凭据的正确方法吗?
最佳答案
您还可以使用:
request.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
关于c# - 如何将凭据传递到httpwebrequest以访问SharePoint库,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5190196/