Click here to Skip to main content
11,580,580 members (71,872 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET Windows C#4.0 HTTP , +
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
Posted 18-Apr-13 18:15pm
Edited 18-Apr-13 19:28pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 1,088
1 Sergey Alexandrovich Kryukov 750
2 Abhinav S 638
3 Suvendu Shekhar Giri 433
4 F-ES Sitecore 420


Advertise | Privacy | Mobile
Web03 | 2.8.150603.1 | Last Updated 19 Apr 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100