HttpWebRequest over HTTPS问题[已解决] [英] HttpWebRequest over HTTPS issue [SOLVED]
问题描述
大家好,
我正在使用HttpWebRequest获取OWA的忙/闲信息.当Web请求通过HTTP发出时,我的方法运行良好,但是一旦将其更改为HTTPS,我会收到看起来像HTML页面内容的内容? :confused :: confused:好像没有进行身份验证...
我尝试了以下网站的建议: httpwebrequest-over-ssl-with-client-credentials [ ^ ],但结果相同.
这是我的代码:
Hi all,
I am making use of a HttpWebRequest to get free/busy information for OWA. My method is working perfectly when the web request occurs over HTTP, but as soon as I change it to HTTPS I receive what looks like the content of a HTML page? :confused::confused: It''s like the authentication did not occur...
I have tried what the following site suggested: httpwebrequest-over-ssl-with-client-credentials[^], but was left with the same result.
Here is my code:
ServicePointManager.ServerCertificateValidationCallback =
delegate(Object obj, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
return true;
};
HttpWebRequest httpWRequest = (HttpWebRequest)WebRequest.Create(string.Concat("https://server/public/?cmd=freebusy&start=", timeFrom.ToString("s"), "+02:00&end=", timeTo.ToString("s"), "+02:00&interval=", IntervalInMinutes.ToString(), "&u=SMTP:", entityID));
httpWRequest.Credentials = new NetworkCredential(this.txtUsername.Text, this.txtPassword.Text);
httpWRequest.KeepAlive = false;
httpWRequest.PreAuthenticate = true;
httpWRequest.Headers.Set("Pragma", "no-cache");
httpWRequest.ContentType = "text/xml";
httpWRequest.Method = "GET";
httpWRequest.Headers.Add("Translate", "t");
httpWRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1)";
HttpWebResponse httpWResponse = (HttpWebResponse)httpWRequest.GetResponse();
Stream strm = httpWResponse.GetResponseStream();
StreamReader sr = new StreamReader(strm);
string text = sr.ReadToEnd();
this.rTxtOutput.Text = string.Format("Http Web Response: {0}\n\n", text);
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(text);
XmlNamespaceManager nsmngr = new XmlNamespaceManager(xmlDoc.NameTable);
nsmngr.AddNamespace("a", "WM");
XmlNode nodeFreeBusy = xmlDoc.SelectSingleNode("a:response/a:recipients/a:item[2]/a:fbdata", nsmngr);
if (nodeFreeBusy.InnerText != string.Empty)
{
sAvailability = nodeFreeBusy.InnerText;
}
任何指针吗?
提前非常感谢.
亲切的问候,
Any pointers??
Many thanks in advance.
Kind regards,
推荐答案
ANSWER:
以编程方式访问-owa [ ^ ]
亲切的问候,
ANSWER:
access-to-owa-programmatically[^]
Kind regards,
这篇关于HttpWebRequest over HTTPS问题[已解决]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!