title: ProtocolViolationException is thrown on GetRequestStream() with a post method
body: <p>I have created a basic RESTful service in .NET that allows me to make basic Get and Post calls to a Uri that is specified by the calling method.  In my post method, I am attempting to call GetRequestStream with my HttpWebRequest, however I get a ProtocolViolationException with the message "Cannot send a content-body with this verb-type."</p>  I know that this can be caused by having the HttpWebRequest method set to Get, however I have debugged and made sure that the method is Post when the GetRequestStream call is made.   I can't figure out why this is being thrown.  Can anyone help me out?  The code is below</p>
  
  <pre><code>public HttpWebResponse Get(bool followRedirect = true)
      {
          _webRequest.Method = WebRequestMethods.Http.Get;
          _webRequest.AllowAutoRedirect = followRedirect;
          _webRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
          var webResponse = _webRequest.GetResponse() as HttpWebResponse;
  
          _webRequest.CookieContainer.Add(webResponse.Cookies);
          return webResponse;
      }
  
  
  
      public HttpWebResponse Post(string contentType, Dictionary&lt;String,String&gt; parameters, bool followRedirect = true)
      {
          _webRequest.Method = WebRequestMethods.Http.Post;
          _webRequest.AllowAutoRedirect = followRedirect;
  
          var postData = "";
          foreach (var parameter in parameters)
          {
              postData += HttpUtility.UrlEncode(parameter.Key) + "=" +
                          HttpUtility.UrlEncode((parameter.Value)) + "&amp;";
          }
          postData = postData.Remove(postData.Length - 1, 0);
  
          var data = Encoding.UTF8.GetBytes(postData);
          _webRequest.ContentType = contentType;
  
          var requestStream = _webRequest.GetRequestStream();
          requestStream.Write(data, 0, data.Length);
          requestStream.Close();
  
          var webResponse = _webRequest.GetResponse() as HttpWebResponse;
          return webResponse;
      }
  </code></pre>
  
  <h2>Edit</h2>
  
  <p>I discovered that the problem was being caused by calling _webRequest.GetResponse() and then later, I use that same _webRequest to call GetRequestStream().  Is this kind of behavior expected?  That is, can a WebRequest only make one of those calls before it needs to be reinitialized/reset? </p>
  
  <p>I made a fix by basically making a new WebRequest in Post and copying values from _webRequest to it, but I would like to know if that is necessary or if a more robust solution is possible.</p>