WCF Request Scope Variables

前端 未结 2 642
温柔的废话
温柔的废话 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

    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.

提交回复
热议问题