I want to implement ThrottlingHandler.SetIdentity so that it fetches the ClientId from a application/x-www-form-urlencoded POST like:
POST /WebAPI.DemoThrottle/Values/Throttle HTTP/1.1
Host: localhost:63621
Content-Type: application/x-www-form-urlencoded
ClientId=MyClientId&OtherParam=123
I came up with the following:
protected override RequestIdentity SetIdentity(HttpRequestMessage request) { var form = request.Content.ReadAsFormDataAsync().Result; var clientId = form["ClientId"];
But this seems to remove the body from the Action in the controller:
public async Task<IHttpActionResult> Throttle([FromBody] ThrottleData throttle)
I want to implement ThrottlingHandler.SetIdentity so that it fetches the ClientId from a application/x-www-form-urlencoded POST like:
POST /WebAPI.DemoThrottle/Values/Throttle HTTP/1.1 Host: localhost:63621 Content-Type: application/x-www-form-urlencoded
ClientId=MyClientId&OtherParam=123
I came up with the following:
protected override RequestIdentity SetIdentity(HttpRequestMessage request) { var form = request.Content.ReadAsFormDataAsync().Result; var clientId = form["ClientId"];
But this seems to remove the body from the Action in the controller:
public async Task<IHttpActionResult> Throttle([FromBody] ThrottleData throttle)
and throttle will be null.
Any suggestions or am I doing this the wrong way?