से अधिक HttpWebRequest के साथ एक अनुरोध भेजने मैं क्लासिक एएसपी में निम्नलिखित स्निपेट, एक कमांड भेजने और SSL पर प्रतिक्रिया प्राप्त करने के लिए है:त्रुटि 502 (ख़राब प्रवेश द्वार) जब एसएसएल
Dim xmlHTTP
Set xmlHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0")
xmlHTTP.open "POST", "https://www.example.com", False
xmlHTTP.setRequestHeader "Content-Type","application/x-www-form-urlencoded"
xmlHTTP.setRequestHeader "Content-Length", Len(postData)
xmlHTTP.Send postData
If xmlHTTP.status = 200 And Len(message) > 0 And Not Err Then
Print xmlHTTP.responseText
End If
तो मैं एक के रूप में इस्तेमाल किया this code
private static string SendRequest(string url, string postdata)
{
WebRequest rqst = HttpWebRequest.Create(url);
// We have a proxy on the domain, so authentication is required.
WebProxy proxy = new WebProxy("myproxy.mydomain.com", 8080);
proxy.Credentials = new NetworkCredential("username", "password", "mydomain");
rqst.Proxy = proxy;
rqst.Method = "POST";
if (!String.IsNullOrEmpty(postdata))
{
rqst.ContentType = "application/x-www-form-urlencoded";
byte[] byteData = Encoding.UTF8.GetBytes(postdata);
rqst.ContentLength = byteData.Length;
using (Stream postStream = rqst.GetRequestStream())
{
postStream.Write(byteData, 0, byteData.Length);
postStream.Close();
}
}
((HttpWebRequest)rqst).KeepAlive = false;
StreamReader rsps = new StreamReader(rqst.GetResponse().GetResponseStream());
string strRsps = rsps.ReadToEnd();
return strRsps;
}
समस्या है, जब GetRequestStream बुला मैं संदेश "The remote server returned an error: (502) Bad Gateway."
पहले मैंने सोचा था कि इसे SSL प्रमाणपत्र सत्यापन के साथ करना था। इसलिए मैं इस लाइन कहा:
ServicePointManager.CertificatePolicy = new AcceptAllCertificatePolicy();
कहाँ
public class AcceptAllCertificatePolicy : ICertificatePolicy
{
public bool CheckValidationResult(ServicePoint srvPoint,
System.Security.Cryptography.X509Certificate certificate,
WebRequest request,
int certificateProblem)
{
return true;
}
}
और मैं एक ही 502 त्रुटि मिलती रहती है। कोई विचार?
बहुत बढ़िया सलाह:
प्रॉक्सी से प्रतिक्रिया शरीर कुछ इस तरह देखा! इसका उपयोग करके मैंने समस्या के बारे में कुछ और पाया और समाधान के साथ आया। धन्यवाद। – Leonardo