title: How to get hold of Content that is already read
body: <p>I have a class that inherits from ApiController.  It has a Put-method like this:</p>
  
  <pre><code>[PUT("user/{UserId}")]
  public HttpResponseMessage Put(string userId, PaymentRequest paymentRequest)
  {
      // Calling business logic and so forth here
      // Return proper HttpResponseMessage here
  }
  </code></pre>
  
  <p>The method works fine as it is above.  Now I need to validate the signature of the method call, but here I run into a problem.  The signature is essentially a combination of method + url + body.  The method I can get by calling Request.Method and the url I can get by calling Request.RequestUri.ToString(), but I can't get hold of the body as it was <strong><em>before</em></strong> it was automatically deserialized into a PaymentRequest object by the asp.net MVC4 framework.</p>
  
  <p><strong>My first try:</strong>
  As I have now understood Request.Content.ReadAsStringAsync().Result returns nothing.  This is because the content can only be read once.</p>
  
  <p><strong>My second try:</strong>
  I tried to serialize it back to a JSON string.   </p>
  
  <pre><code>var serializer = new JavaScriptSerializer();
  var paymentRequestAsJson = serializer.Serialize(paymentRequest);
  </code></pre>
  
  <p>The problem with this is that the formatting turns out slightly different than the body part of the signature.  It has the same data, but some more spaces. </p>
  
  <p>I can't change what the caller of my Put-method does, as this is a third party component.  What should I do?</p>