Sending http request to server using C#.net
-
hello sir, I have a problem while developing an appliation in which i have to send http request to server and then receive response from server please help me
Check out this article http://www.codeproject.com/useritems/Browsing_the_WEB_with_C_.asp[^]
Vasudevan Deepak Kumar Personal Homepage Tech Gossips
-
hello sir, I have a problem while developing an appliation in which i have to send http request to server and then receive response from server please help me
-
hello sir, I have a problem while developing an appliation in which i have to send http request to server and then receive response from server please help me
I .Net Framework 2 there is a very useful calls called the System.Net.WebClient class. This class contains methods that allow you to quickly make http and https requests and process the return. You can set headers and post information. I have used it to create a http post to remote servers and receive a response. Here is some code:
Byte [] PostData = System.Text.Encoding.ASCII.GetBytes("hello world"); System.Net.WebClient client = new System.Net.WebClient(); Byte[] Response = oClient.UploadData("http://www.somewhereintheworld.com", "POST", PostData); return System.Text.Encoding.ASCII.GetString(Response);
These first line just turns the post data I want to send into a byte array. I create the WebClient object on the second line and then on the third line I tell the client to send the data to the target website as a post action with the byte array I have created. This returns a byte array that I then need to turn back into a string which is done on the last line. Happy browsing.