Attribute Routing Values into Model/FromBody Parameter
<p>When using attribute routing in Web API (2), I would like to be able to get route parameters from the URL into the model parameter automatically.  The reason for this is that my validation is performed in a filter before it reaches the action, and without this the additional information is not easily available.</p>

<p>Consider the following simplified example:</p>

<pre><code>public class UpdateProductModel
{
    public int ProductId { get; set; }
    public string Name { get; set; }
}

public class ProductsController : ApiController 
{
    [HttpPost, Route("/api/Products/{productId:int}")]
    public void UpdateProduct(int productId, UpdateProductModel model) 
    {
         // model.ProductId should == productId, but is default (0)
    }
}
</code></pre>

<p>Sample code to post to this:</p>

<pre class="lang-js prettyprint-override"><code>$.ajax({
    url: '/api/Products/5',
    type: 'POST',
    data: {
        name: 'New Name'   // NB: No ProductId in data
    }
});
</code></pre>

<p>I want the <code>ProductId</code> field in the model to be populated from the route parameters before entering the action method (i.e. so it will be available to my validators).</p>

<p>I'm not sure which part of the model binding process I need to try and override here - I think it's the bit which would handle the <code>[FromBody]</code> part (which is the model parameter in this example).</p>

<p>It is not acceptable to set this within the action itself (e.g. <code>model.ProductId = productId</code>) as I need this to have been set before it reaches the action.</p>