sending username via "get" method...

yaniv

Centurion
Joined
Apr 15, 2002
Messages
167
Location
israel
i need to send user name property in "get" method to another site (they only need it in "get")...

how can i build the code to send the stream? i looking in exmples for hours... but can't find the way... please...
 
yaniv said:
i need to send user name property in "get" method to another site (they only need it in "get")...

how can i build the code to send the stream? i looking in exmples for hours... but can't find the way... please...
Just do a normal web request and programmatically insert the fields into the URL. There are several classes in the framework for doing this.

Look at the page specified in HTML form's ACTION element and use that as your base URL, then tack on "?fieldName1=value1&fieldName2=value2". If the page expects a page to be submitted with the "GET" method, then it probably doesn't care how you get there -- just that you have the required fields in the URL itself.
 
but i want to do it from the code behind... it supposed to be some thing about increasing mail box size, and i need to connect it to the database, and don't give the users a way to see the stream...
 
Well, the user's wouldn't see it. Just use something like the WebClient class, which is in the System.Net namespace.

Code:
const string URL= "http://www.yoursite.com/action_page.php";

string fields = "?txtField1=somevalue1&txtField2=somevalue2";

WebClient wc = new WebClient();

byte[] buffer = wc.DownloadData(URL + fields);
string html = System.Text.Encoding.ASCII.GetString(buffer);

Console.WriteLine( html );
It is important to remember that "action_page.php" must be the page that is being submitted to and not the page that the actual HTML form is on. Also, you must have the appropriate fields in the "fields" string and know how to specify values for them in the same manner HTML does. If you don't know how, then create a dummy form (copy and paste the page's source locally) and practice in order to get the string right.
 
Back
Top