why when i try to send http post , my Project for a few sec send not responding
my code
string ResP = "";
System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
req.ContentLength = bytes.Length;
System.IO.Stream os = req.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
os.Close();
System.Net.WebResponse resp = req.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
ResP = sr.ReadToEnd().Trim();

Ashutosh PathakRank #3,615 · 403 reputationPosted Jul 16, 2014, 11:59 PM EDT
Below is the solution where i used thread to resolve the problem try and see if it helps:
Ashutosh PathakRank #3,615 · 403 reputationPosted Jul 15, 2014, 6:36 AM EDT
-----------------------------------------------------------------------------------------
string field1 = "abcd";
string Parameters = "field1=" + field1;
string ResP = "";
System.Net.WebRequest req = System.Net.WebRequest.Create("http://localhost:25128/WebForm1.aspx");
req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
req.ContentLength = bytes.Length;
System.IO.Stream os = req.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
os.Close();
System.Net.WebResponse resp = req.GetResponse();
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
ResP = sr.ReadToEnd().Trim();
--------------------------------------------------------------------------------------------------
/* code for web page WebForm1.aspx*/
protected void Page_Load(object sender, EventArgs e)
{
HttpContext.Current.Response.Write("Ashutosh");
}
XIII XIII14 reputationPosted Jul 15, 2014, 1:22 PM EDT
for e.g
}
//////////////////////////////////////////////////////////////////////////////////////
public static string HttpPost(string URI, string Parameters, string PROXY)
WebProxy Prxy = new WebProxy(PROXY, true) ;
req.Proxy = PROXY;
return ResP;
}
Ashutosh PathakRank #3,615 · 403 reputationPosted Jul 15, 2014, 11:27 PM EDT
Before return the response in HttpPost function try adding this to your code and see if it helps:
resp.Close();
XIII XIII14 reputationPosted Jul 16, 2014, 12:29 PM EDT
tnx bro For answering <3
XIII XIII14 reputationPosted Jul 17, 2014, 2:53 PM EDT
how i can put result in TextBox in ur code?
Ashutosh PathakRank #3,615 · 403 reputationPosted Jul 21, 2014, 7:33 AM EDT
you can write this
but this code cannot give the guarantee of web request response order hence you have to observe in a loop that all responses are captured and all values are set in responseResult object then you can easily iterate in this array and set your text in textbox