Add multiple parameters using HTTPOperationHandler

Topics: Web Api
Sep 9, 2011 at 9:31 AM


In the post where Pablo describes using OperationHandler to add a parameter IPrincipal.

This example is great in cases where you need to add just 1 parameter.

How can I add 2 or 3 parameters using OperartionHandlers?

I am struggling to understand implementing OnHandle function for more than 1 parameter.


Sep 9, 2011 at 9:47 AM

You must derive directly from  HttpOperationHandler and not from the generic specializations.


1) Define the multiple output parameters on the OnGetOutputParameters method

2) Return the multiple outputs on the OnHandle method (notice that the return type is object[])



Sep 12, 2011 at 9:03 AM


But I see that OnHandle doesn't take any HttpRequestMessage parameter.

How can I implement some logic that uses HttpRequestMessage in OnHandle method?


Sep 12, 2011 at 12:21 PM

Create an input parameter of type HttpRequestMessage and it will automatically get populated by the pipeline.

Dec 13, 2011 at 3:00 PM
Edited Dec 13, 2011 at 10:26 PM

I was able to implement an Operation handler which produces multiple parameters (say of CustomType1 and CustomType2). However, when defining both parameter in the operation method, I a,m getting the error message: "System.InvalidOperationException: The HttpOperationHandlerFactory is unable to determine the input parameter that should be associated with the request message content for service operation 'Faxtest'. If the operation does not expect content in the request message use the HTTP GET method with the operation. Otherwise, ensure that one input parameter either has it's IsContentParameter property set to 'True' or is a type that is assignable to one of the following: HttpContent, ObjectContent`1, HttpRequestMessage or HttpRequestMessage`1.".

When limiting the number of parameters to a single one (of either of the custom types) , the service works fine (parameter is properly passed to method).

Is this not allowed ?

Jan 27, 2012 at 6:51 PM

This issue seems to have been resolved in version 6.0 (beta)