T
Tom
Dear all,
when I ran the following code, I always got "The underlying connection was closed: An unexpected error occurred on a send" error, it happend at "httpReq.GetResponse();" and the stack trace is
************start of stack trace***************************
The underlying connection was closed: An unexpected error occurred on a send. at System.Net.HttpWebRequest.CheckFinalS
tatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.HttpWebRequest.GetResponse()
***********end of stack trace**************88
Much appreciated for any help!
Tom
****************************************************
try
{
HttpWebRequest httpReq = (HttpWebRequest) WebRequest.Create("https://test/kkk");
httpReq.ContentType = "text/xml";
httpReq.Method = "POST";
httpReq.KeepAlive=false;
byte[] requestbody = Encoding.UTF8.GetBytes("<test>kkk</test>");
Stream requestStream = httpReq.GetRequestStream();
int length = requestbody.Length;
requestStream.Write(requestbody,0,length);
requestStream.Close();
X509Certificate x509 = X509Certificate.CreateFromCertFile("C:\\kk\\509cer.cer");
ttpReq.ClientCertificates.Add(x509);
HttpWebResponse webResponse = (HttpWebResponse) httpReq.GetResponse();
}
catch (WebException ex)
{
Response.Write(ex.Message);
}
catch (Exception err)
{
Response.Write(err.Message);
}
when I ran the following code, I always got "The underlying connection was closed: An unexpected error occurred on a send" error, it happend at "httpReq.GetResponse();" and the stack trace is
************start of stack trace***************************
The underlying connection was closed: An unexpected error occurred on a send. at System.Net.HttpWebRequest.CheckFinalS
tatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.HttpWebRequest.GetResponse()
***********end of stack trace**************88
Much appreciated for any help!
Tom
****************************************************
try
{
HttpWebRequest httpReq = (HttpWebRequest) WebRequest.Create("https://test/kkk");
httpReq.ContentType = "text/xml";
httpReq.Method = "POST";
httpReq.KeepAlive=false;
byte[] requestbody = Encoding.UTF8.GetBytes("<test>kkk</test>");
Stream requestStream = httpReq.GetRequestStream();
int length = requestbody.Length;
requestStream.Write(requestbody,0,length);
requestStream.Close();
X509Certificate x509 = X509Certificate.CreateFromCertFile("C:\\kk\\509cer.cer");
ttpReq.ClientCertificates.Add(x509);
HttpWebResponse webResponse = (HttpWebResponse) httpReq.GetResponse();
}
catch (WebException ex)
{
Response.Write(ex.Message);
}
catch (Exception err)
{
Response.Write(err.Message);
}