Hello friends Good Morning
I am facing a problem from last few days.. I have a window application which is sending request to another applications and it get the response from other application.
Now the problem is this that if i run my application in any another system i will get the response from from another application but when i use this application in my system then its throw an exception that
CONNECTION WAS ABORTED BY HOST MACHINE
please tell me why it is happening here is the my code which i am using
public string tm4b(string sURL, bool bEscapeURL, string sPostData)
{
sURL = sURL.Trim();
while (sURL.IndexOf(" ") > 0)
{
sURL = sURL.Replace(" ", " ");
}
System.Text.StringBuilder sb = new System.Text.StringBuilder();
string stmp = string.Empty;
Uri httpUri = new Uri(sURL, bEscapeURL);
try
{
System.Text.ASCIIEncoding byteConverter = new System.Text.ASCIIEncoding();
byte[] byte1 = byteConverter.GetBytes(sPostData);
System.Net.HttpWebRequest hwRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(httpUri);
hwRequest.ContentType = "application/x-www-form-urlencoded";
hwRequest.Method = "POST";
hwRequest.ContentLength = sPostData.Length; ;
System.IO.Stream PostStream = hwRequest.GetRequestStream();
PostStream.Write(byte1, 0, byte1.Length);
System.Net.HttpWebResponse hwResponse = (System.Net.HttpWebResponse)hwRequest.GetResponse();
System.IO.StreamReader sRead = new System.IO.StreamReader(hwResponse.GetResponseStream(),
System.Text.Encoding.ASCII);
if ((stmp = sRead.ReadLine()) != null)
{
sb.Append(stmp + "");
}
PostStream.Close();
sRead.Close();
return sb.ToString();
}
catch (Exception ex)
{
return "error";
}
return "Request Error";
}
Please tell me what is going wrong if you get it