C# .NET - Http Request and Response is not working

Asked By azad chouhan on 19-Apr-13 12:40 AM
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 

01.public string tm4b(string sURL, bool bEscapeURL, string sPostData)
02.{
03.sURL = sURL.Trim();
04.while (sURL.IndexOf(" ") > 0)
05.{
06.sURL = sURL.Replace(" ", " ");
07.}
08.System.Text.StringBuilder sb = new System.Text.StringBuilder();
09.string stmp = string.Empty;
10.Uri httpUri = new Uri(sURL, bEscapeURL);
11.try
12.{
13.  
14.System.Text.ASCIIEncoding byteConverter = new System.Text.ASCIIEncoding();
15.byte[] byte1 = byteConverter.GetBytes(sPostData);
16.System.Net.HttpWebRequest hwRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(httpUri);
17.  
18.hwRequest.ContentType = "application/x-www-form-urlencoded";
19.hwRequest.Method = "POST";
20.  
21.hwRequest.ContentLength = sPostData.Length; ;
22.System.IO.Stream PostStream = hwRequest.GetRequestStream();
23.PostStream.Write(byte1, 0, byte1.Length);
24.System.Net.HttpWebResponse hwResponse = (System.Net.HttpWebResponse)hwRequest.GetResponse();
25.System.IO.StreamReader sRead = new System.IO.StreamReader(hwResponse.GetResponseStream(),
26.System.Text.Encoding.ASCII);
27.  
28.if ((stmp = sRead.ReadLine()) != null)
29.{
30.  
31.sb.Append(stmp + "");
32.  
33.}
34.  
35.PostStream.Close();
36.sRead.Close();
37.  
38.return sb.ToString();
39.  
40.}
41.catch (Exception ex)
42.{
43.  
44.return "error";
45.}
46.return "Request Error";
47.  
48.}

Please tell me what is going wrong if you get it
Robbe Morris replied to azad chouhan on 19-Apr-13 07:03 AM
Could be a firewall issue on the server or on your desktop.  You could try making a request to google.com or cnn.com and see if that gets through.  That would at least rule out a firewall rule on your desktop.

Could also be a ClientPolicy.xml file issue on the web server you are trying to connect to.  The server may disallow you for some reason.