c# - Pass Value to BeforeSendRequest in WCF -


i want pass additional value( guid, different each request) beforesendrequest in wcf iclientmessageinspector interface. value not include in request object. how can pass value beforesendrequest method?

public class wcfmessageinterceptor : idispatchmessageinspector, iclientmessageinspector {     [threadstatic]     private static string service1guid;      public object afterreceiverequest(ref message request, iclientchannel channel, instancecontext instancecontext)     {         service1guid = request.headers.getheader("service1-guid-header", "s");     }      public object beforesendrequest(ref message request, iclientchannel channel)     {         var servicename="";         if (channel != null && channel.remoteaddress != null)         {             var tmp = request.headers.action.substring(0, request.headers.action.lastindexof('/'));             servicename = tmp.substring(tmp.lastindexof('/') + 1);         }         var methodname = request.headers != null                                 ? request.headers.action.substring(request.headers.action.lastindexof('/') + 1)                                 : "action";         //check if called service right 1         if(servicename=="service2"){             var typedheader = new messageheader(service1guid);             var untypedheader = typedheader.getuntypedheader("service1-guid-in-service2-header", "s");             request.headers.add(untypedheader);         }     } } 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -