title: How do I retrieve body values from an HTTP POST request in an ASP.NET Web API ValueProvider?
body: <p>I want to send a HTTP POST request with the body containing information that makes up a simple blog post, nothing fancy.</p>
  
  <p>I've read <a href="http://www.asp.net/web-api/overview/formats-and-model-binding/parameter-binding-in-aspnet-web-api" rel="noreferrer">here</a> that when you want to bind a complex type (i.e. a type that is not <code>string</code>, <code>int</code> etc) in Web API, a good approach is to create a custom model binder.</p>
  
  <p>I have a custom model binder (<code>BlogPostModelBinder</code>) that in turn uses a custom Value Provider (<code>BlogPostValueProvider</code>). What I don't understand is that how and where shall I be able to retrieve the data from the request body in the <code>BlogPostValueProvider</code>?</p>
  
  <p>Inside the model binder this is what I thought would be the right way to for example retrieve the title.</p>
  
  <pre><code>public bool BindModel(HttpActionContext actionContext, ModelBindingContext bindingContext)
  {
     ...
     var title= bindingContext.ValueProvider.GetValue("Title");
     ...
  }
  </code></pre>
  
  <p>while the BlogPostValueProvider looks like this:</p>
  
  <pre><code> public class BlogPostValueProvider : IValueProvider
   {
      public BlogPostValueProvider(HttpActionContext actionContext)
      {
         // I can find request header information in the actionContext, but not the body.
      }
  
      public ValueProviderResult GetValue(string key)
      {
         // In some way return the value from the body with the given key.
      }
   }
  </code></pre>
  
  <p>This might be solvable in an easier way, but since i'm exploring Web API it would be nice to get it to work.</p>
  
  <p>My problem is simply that I cannot find where the request body is stored.</p>
  
  <p>Thanks for any guidance!</p>