I need to send an HTTP POST request to the server, but it should not wait for a response. What method should I use for this?
I used
WebRequest request2 = WebRequest.Create("http://local.ape-project.org:6969"); request2.Method = "POST"; String sendcmd = "[{\"cmd\":\"SEND\",\"chl\":3,\"params\":{\"msg\":\"Helloworld!\",\"pipe\":\"" + sub1 + "\"},\"sessid\":\"" + sub + "\"}]"; byte[] byteArray2 = Encoding.UTF8.GetBytes(sendcmd); Stream dataStream2 = request2.GetRequestStream(); dataStream2.Write(byteArray2, 0, byteArray2.Length); dataStream2.Close(); WebResponse response2 = request2.GetResponse();
send a request and get a response. This works fine if the request receives a response from the server. But for my need, I just need to send a POST request. And there will be no response related to the request that I am sending. How to do it?
If I use the request2.GetRespnse () command, I get a "Connection unexpectedly closed" error message
Any help would be appreciated. thanks
source share