如何从HTTPS
地址读取数据?
当我尝试从http://www.w3schools.com/xml/note.xml
获取数据时,我的代码工作正常,但在我尝试访问https://live.af.centurylink.com/PRISMPOC/AFTelephonyRWS/restful/3032971029/call?token=082b96247aa6c2cce2007e9270eeabe1485988d17c3d832553cf562f0f6aef96&maximumnumberofrecords=10
时失败
有错误:
远程服务器返回错误:(403)Forbidden。
我的代码是:
HttpWebRequest webRequest = (HttpWebRequest)HttpWebRequest.Create(url);
webRequest.Method = "GET";
webRequest.Proxy = WebRequest.DefaultWebProxy;
webRequest.Credentials = new NetworkCredential("mp0010484", "mp00com", "domain");
webRequest.Proxy.Credentials = new NetworkCredential("mp0010484", "mp00com", "domain");
webRequest.Proxy = WebRequest.DefaultWebProxy;
using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
{
using (StreamReader streamReader = new StreamReader(webResponse.GetResponseStream()))
{
XDocument document = XDocument.Load(new StringReader(streamReader.ReadToEnd()));
string xml = document.Root.ToString();
MessageBox.Show(xml);
}
}