Click here to Skip to main content
13,047,131 members (58,674 online)
Rate this:
Please Sign up or sign in to vote.
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


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);
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(),
if ((stmp = sRead.ReadLine()) != null)
sb.Append(stmp + "");
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
Updated 18-Apr-13 19:28pm

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 19 Apr 2013
Copyright © CodeProject, 1999-2017
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