I've got a web api that takes in a model
[CustomAuthorize]
public HttpResponseMessage UpdateStatus(Model model)
In the customAuthorize I have to read the contents of the request to validate it's not hacked
class CustomAuthorizeAttribute : AuthorizationFilterAttribute
{
public override void OnAuthorization(HttpActionContext context)
{
var content = context.Request.Content.ReadAsFormDataAsync().Result;
}
}
When I have the CustomAttribute applied to the web api, the model always comes back null. The binding doesn't happen. I've tried to use some cloning methods found here to clone the request and use that for the authorization but that doesn't seem to work either. How to clone a HttpRequestMessage when the original request has Content?
Does anyone know how I can retain the HttpContent in the request to let it bind to the method?