I am trying to login programatically to a sharepoint app and get the html code of specific page within that website. Is there a way how I can do that programatically? I am having problems with the part where I need to pass the login parameters and access the url I need to get the html code. Thanks in advance everyone, Laziale
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://mysite.sharepoint.com");
NetworkCredential credentials = new NetworkCredential(开发者_如何转开发"myUser", "myPass");
request.Credentials = credentials;
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream receiveStream = response.GetResponseStream ();
StreamReader readStream = new StreamReader (receiveStream, Encoding.UTF8);
string html = readStream.ReadToEnd();
response.Close();
readStream.Close();
Have you tried something like:
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("url goes here");
request.Credentials = new NetworkCredential("username", "password");
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream receiveStream = response.GetResponseStream ();
StreamReader readStream = new StreamReader (receiveStream, Encoding.UTF8);
string html = readStream.ReadToEnd();
response.Close();
readStream.Close();
精彩评论