I'm getting some values in AfterReceiveRequest and want to use that in BeforeSendReply in WCF. Please help me, how I can do that. I'm working in C# project files. I can't use Seesion, ViewState here. I can use
static fields, but It will not a good solution. Please give me best solution for this.
Below are some lines of my code.
public object AfterReceiveRequest(
ref System.ServiceModel.Channels.Message request,
System.ServiceModel.IClientChannel channel,
System.ServiceModel.InstanceContext instanceContext)
{
ClassABC abc = new ClassABC();
int webServiceID = abc .SetInformation(--//any parameters//--);
return null;
}
public void BeforeSendReply(ref System.ServiceModel.Channels.Message reply,
object correlationState)
{
//here I need webServiceID.
}
That's what the correlationState value is for. Basically, whatever object you return from AfterReceiveRequest() will be passed to you again on the correlationState parameter of BeforeSendReply().
Just stick all the info you need into an object and pass it around that way.