Hi all,
I need to post a data to a secure site that looks like https://abcdef.asp" and that site returns response depends upon what you sent to that using asp.net.
I used the following code but, I got some error like "The underlying connection was closed. Could not established trust realitionship for the SSL/TLS secure channel".
My code:
private string TransferXML(string strXML)
{
string TxRequest = strXML;
WebRequest req = null;
WebResponse rps = null;
string strUrlToTravelers = ConfigurationManager.AppSettings["urlToTravelers"].ToString();
req = WebRequest.Create(strUrlToTravelers);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
StreamWriter wr = new StreamWriter(req.GetRequestStream());
wr.WriteLine(TxRequest);
wr.Close();
rps = req.GetResponse();
if (!req.Equals(null))
{
req.GetRequestStream().Close();
}
if (!rps.Equals(null))
{
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(strUrlToTravelers);
//httpWebRequest.KeepAlive = false;
HttpWebResponse httpWebResponse = (HttpWebResponse)(httpWebRequest.GetResponse());
}
Stream receiveStream = rps.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader readStream = new StreamReader(receiveStream, encode);
TxRequest = readStream.ReadToEnd();
readStream.Close();
rps.Close();
}
catch(Exception ex)
{
Response.Write(ex.Message.ToString());
}
finally
{
}
return TxRequest;
}
After all I could not ge the value from secure connection.
I should be happy if any one answer to my question as soon as possible.
Thanks
R. Eswaran