I've never used multipart/form-data before and it seems a little tricky to me and I can't understand how to post the required data.
Here is the code I've written so far:
string urlRequestRegister = "http://iwebsite.com/user/register";
string boundary = "----------------------------" + DateTime.Now.Ticks.ToString("x");
CookieContainer cookie = new CookieContainer();
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(urlRequestRegister);
request.Method = "POST";
request.ContentType = string.Format("multipart/form-data; boundary={0}", boundary);
request.Credentials = CredentialCache.DefaultCredentials;
request.CookieContainer = cookie;
request.KeepAlive = true;
byte[] boundary_bytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
string form_data_template = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
}
catch (Exception error)
{
MessageBox.Show(error.ToString());
}
Form_data_template parameters should be the name of the field and the value but I really don't know how I'm supposed to create the entire PostURL.
I need to post only fields like : thewebsite.com/user/register?id=value&name=value&age=value&submit=ok
I've researched a lil. bit but I've found only complicated things on the internet.
Could someone help me?
Thanks