How to send data ( fields ) to an URL?
How do I send some data to an URL? I seen some examples of "HttpWebRequest" but they all send only one string of "data" to the URL.
I need to send a couple of fields, like a big text field ( textarea like ) and other fields with names and values.
any idéas?
Edit : Solved, sort'a
Found this on some site :
Code:
private void OnPostInfoClick(object sender, System.EventArgs e)
{
string strId = UserId_TextBox.Text;
string strName = Name_TextBox.Text;
ASCIIEncoding encoding=new ASCIIEncoding();
string postData="userid="+strId;
postData += ("&username="+strName);
byte[] data = encoding.GetBytes(postData);
// Prepare web request...
HttpWebRequest myRequest =
(HttpWebRequest)WebRequest.Create("http://localhost/MyIdentity/Default.aspx");
myRequest.Method = "POST";
myRequest.ContentType="application/x-www-form-urlencoded";
myRequest.ContentLength = data.Length;
Stream newStream=myRequest.GetRequestStream();
// Send the data.
newStream.Write(data,0,data.Length);
newStream.Close();
}
Have not tested it but I'm gonna use XML instead so my problem is solved now.