C# .NET - [Help me] How to use c# to POST data and retrive

Asked By zero device on 13-Apr-06 02:47 AM
i am writing a small tool for myself just to allow me to login to a phpbb forum from a C# application.

let's say i got:
forum address: http://www.honghong.net/honghongforum/
[textbox] - txtUser
[textbox] - txtPass
[checkbox] - chkRememberMe
[button] - btnLogin


how can I send those data above to the forum then get the "forum topic" listed into a [listbox] with webrequest and webrespond in c#?

please help me out because i have no clue at all.
Those samples and tutorial i found from internet only shows me how to POST, but did not show me how to retrive the respond.

Thanks.
Asked By Shallu Gupta on 13-Apr-06 02:59 AM
Try this..
[CODE]
WebRequest request = WebRequest.Create(url);
                  WebResponse response = request.GetResponse(); 

                  StreamReader reader = new StreamReader(response.GetResponseStream()); 

                  string str = reader.ReadLine();
                  while(str != null)
                  {
                        Console.WriteLine(str);
                        str = reader.ReadLine();
                  }

[/CODE]
Asked By zero device on 13-Apr-06 03:09 AM
Thanks. but it doesn't show me the page after i login.
it gave me the html without login. and not even the page that says error login.
it's like i've POST the data for login, but retrive a different non-login page.

how do i fix it?
Asked By Shallu Gupta on 13-Apr-06 03:28 AM
check this link if this could help you ..
http://www.c-sharpcorner.com/1/url_dwn.asp
Asked By zero device on 13-Apr-06 03:36 AM
Cheers mate. :)

do u have msn? care to add me in? i am using hotmail with this username.
Asked By Shallu Gupta on 13-Apr-06 04:34 AM
sorry, I dont have it.
You can use the webclient class - Asked By Peter Bromberg on 13-Apr-06 06:39 AM
using System;
using System.Text;
using System.Net;
using System.Collections.Specialized;
//...

string url = "http://www.amazon.co.uk/exec/obidos/search-handle-form";
NameValueCollection formData = new NameValueCollection();
formData["field-keywords"] = "Harry Potter";
// add more form field / values here

WebClient webClient = new WebClient();
byte[] responseBytes = webClient.UploadValues(url, "POST", formData);
string response = Encoding.UTF8.GetString(responseBytes);

Console.WriteLine(response);
cheers - Asked By zero device on 13-Apr-06 11:04 AM
cheers mate.

Next I'll have to figure how to read into the next page(into the forum topic to see the latest reply or threads), because i think the page needs to read cookie to varified I'm the logged in user and display the post/reply threads.
Using Web Client Class - Asked By cg menon on 03-May-06 05:18 AM
i am also trying to post values automatically to an asp page from asp.net application. I need to manipulate the search results.

How do i do this.

I tried ur sample code, but i don't know how to retrieve values from my search results.

NameValueCollection formData = new NameValueCollection(); 
formData["Last_Name"] = "SMITH"; 
formData["Social_Security"] = "244557719"; 
formData["Dob"] = "03/08/1982"; 
WebClient webClient = new WebClient(); 
byte[] responseBytes = webClient.UploadValues("https://www.xyz.com/regver/verification1.asp" , "POST", formData);