WCF Request Scope Variables

前端 未结 2 606
温柔的废话
温柔的废话 2021-01-25 04:39

I\'ve been doing some work extending the WCF pipeline of my service using mainly IOperationInvoker to implement my own functionality.

I am currently using

相关标签:
2条回答
  • 2021-01-25 04:51

    I believe you need to be linked to OperationContext not HttpContext. The answer to similar question is already presented here.

    Basically you just need to implement IExtension and plug it into WCF. Step-by-step example can be found for example here.

    0 讨论(0)
  • 2021-01-25 04:51

    You can setup your service to be Instance context mode of persession.

    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)] 
    public class MyService : IMyService
    {
        private string sessionVar;         // for each session
    }
    

    And then it is up to client to keep the session alive. In your client you can create a proxy at class level and only close it when you are done with it that way you have sessionVar available.

    0 讨论(0)
提交回复
热议问题