470,827 Members | 1,730 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,827 developers. It's quick & easy.

Having problem with WebRequest & HttpWebResponse

I'm using C#.NET WebRequest and HTTPResponse to post data to a server and I'm reading the response into a stream. Does anyone know how to split the returned values like a request.form["Variable"]. Here is the code. Thanks!

WebRequest request = WebRequest.Create("Webiste.com");
request.Method = "POST";
string postData = "";

postData += "Value1=C&";
postData += "Value2=S";

byte[] byteArray = Encoding.UTF8.GetBytes(postData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
dataStream.Write(byteArray, 0, byteArray.Length);

WebResponse reponse = request.GetResponse();

Response.Write(((HttpWebResponse)reponse).StatusDe scription);
dataStream = reponse.GetResponseStream();

StreamReader reader = new StreamReader(dataStream);

string responseFromServer = reader.ReadToEnd();

Jun 26 '06 #1
0 1349

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Adam Stirk | last post: by
1 post views Thread by ¼­°­È£ | last post: by
1 post views Thread by Satinderpal Singh | last post: by
2 posts views Thread by kkb | last post: by
3 posts views Thread by Dave | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.