title: Parsing "multipart/form-data" in .NET/C#
body: <p>Got a .NET/C# question... </p>
  
  <p>I need to parse some input post data thats in a "multipart/form-data" format to extract the passed username and password. Anyone know how to do this without writing my own parsing code?</p>
  
  <p>Note the input post data looks something like this:</p>
  
  <pre><code>---------1075d313df8d4e1d
  Content-Disposition: form-data; name="username"
  
  x@y.com
  ---------1075d313df8d4e1d
  Content-Disposition: form-data; name="password"
  
  somepassword
  ---------1075d313df8d4e1d--
  </code></pre>
  
  <p>To demostrate my code looks something like this at the moment:</p>
  
  <pre><code>[OperationContract]
  [WebInvoke(Method = "POST", UriTemplate = "Login", BodyStyle = WebMessageBodyStyle.Bare)]
  public Stream Login(Stream input)
  {
      string username = String.Empty;
      string password = String.Empty;
  
      StreamReader sr = new StreamReader(input);
      string strInput = sr.ReadToEnd();
      sr.Dispose();
  
      // Help needed here:
      usermame = ?.Parse(strINput, "username");
      password = ?.Parse(strINput, "password");
  
      // blah blah blah return login XML response as a Stream
  }
  </code></pre>