WCF (in the AfterReceiveRequest method of the IDispatchMessageInspector interface)

I get some values ​​in AfterReceiveRequest and want to use this in BeforeSendReply in WCF. Please help me how can I do this. I am working on C # project files. I can not use Seesion, ViewState here. I can use

static fields, but that would not be a good solution. Please give me the 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. } 
+4
source share
1 answer

What the ratioState value is used for. Basically, any object that you return from AfterReceiveRequest () will be passed to you again in the correState parameter of the BeforeSendReply () parameter.

Just insert all the necessary information into the object and pass it that way.

+7
source

Source: https://habr.com/ru/post/1313375/


All Articles