1
我想創建一個Windows應用程序發送警報,如果一個網站關閉,我首先寫了這個基本的形式來檢查它是否工作。http響應代碼SSL網站asp
HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create(textBox1.Text);
httpReq.AllowAutoRedirect = false;
HttpWebResponse httpRes = (HttpWebResponse)httpReq.GetResponse();
if (httpRes.StatusCode == HttpStatusCode.Found)
{
MessageBox.Show("It works.");
}
else
{
MessageBox.Show("Not able to ping");
}
httpRes.Close();
它工作得很好,但是當我想要做的SSL站點相同的(HTTPS),它沒有工作,我看它並添加
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications);
但仍即時通訊不能得到任何迴應從https網站,我嘗試了很多網站,所以我不認爲它與網站的問題,即時通訊新手在.net任何幫助表示讚賞。
你在URL中指定「HTTPS」,不是嗎?當你逐步執行代碼(使用調試器)時,會看到什麼?響應中有什麼? –
證書被接受,但httpres的值仍然設置爲空。 – prasanth