In ASP.NET, if you have an HTTP Module or something similar, you can add additional data to the request context before the request actually gets serviced by the end application using the following:
HttpContext.Current.Items
Is there a similar place (or pattern) for storing adhoc data in the WCF Request Pipeline? Basically, I have custom message inspectors and behaviours that need to be able to communicate small pieces of state to the servicing application.
Ideally there is a solution for .NET 3.5.
You can use message properties for that (they’s essentially a dictionary). In the inspectors you can add them directly to the message. On the operation you can get the properties via the OperationContext.Current.IncomingMessageProperties.
If you want to pass data from the operation to some inspectors which are looking at the response, you’d use the OperationContext.Current.OutgoingMessageProperties.