title: How to post httpWebRequest multipart/form-data
body: <p>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.</p>
  
  <p>Here is the code I've written so far:</p>
  
  <pre><code> 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());
          }
  </code></pre>
  
  <p>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.</p>
  
  <p>I need to post only fields like : thewebsite.com/user/register?id=value&amp;name=value&amp;age=value&amp;submit=ok</p>
  
  <p>I've researched a lil. bit but I've found only complicated things on the internet.</p>
  
  <p>Could someone help me?</p>
  
  <p>Thanks</p>