none
Manage sessions on Server side.

    Question

  • Hello
    Do you know how I can retrieve all sessions informations on a WCF application on the server side?
    I would like to be able to "kill" the session of a specific client based on his IP or SessionID
    Thanks in advance.

    Thibaut
    Wednesday, August 05, 2009 12:02 PM

Answers

  • Hi Thibault,

    You may create the list... however you won't be able to close the session without invoking a service operation... you should use the IsInitiating and IsTerminating properties of the OperationContract attribute for that.... you won't be able to "kill" the sessions from outside of the service...

    Regards,
    Rodrigo.
    Thursday, August 06, 2009 12:46 PM
  • I agree that it is not quite possible to directly terminate a session(or the service instance related to that session) in service-side(without a method call) from WCF client. According to the WCF instance management and lifetime model, the session and instance relationsthip is maintained internally and the possible means for you to explicitly end a session is accessing the OperationContext.Current.InstanceContext.ReleaseServiceInstance method. See the "Instance Deactivation" section in the following article:

    #Discover Mighty Instance Management Techniques For Developing WCF Apps
    http://msdn.microsoft.com/en-us/magazine/cc163590.aspx#S8

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Monday, August 10, 2009 10:40 AM

All replies

  • Hi Thibaut,

    No.. this cannot be done... you cannot "query" external sessions and kill them.
    Maybe we can provide further guidance if you explain what are you trying to achive (authenticate/authorize clients based on IP?)

    Regards,
    Rodrigo.
    Thursday, August 06, 2009 4:10 AM
  • Hi Rodrigo. Thanks for your answer.

    My goal is to have a list of all connected users (current sessions) and found the information about these sessions like sessionsid, client IP,... and display those informations to the application manager (human.
    My application must be session based with a very long timeout, but for business reasons, I would like to be able to kill a specific sessions before the timeout has been reached and without any call from the client otherwise I could implement the "kill" method has a behavior on the server side.

    Regards
    Thibaut
    Thursday, August 06, 2009 7:17 AM
  • Hi Thibault,

    You may create the list... however you won't be able to close the session without invoking a service operation... you should use the IsInitiating and IsTerminating properties of the OperationContract attribute for that.... you won't be able to "kill" the sessions from outside of the service...

    Regards,
    Rodrigo.
    Thursday, August 06, 2009 12:46 PM
  • I agree that it is not quite possible to directly terminate a session(or the service instance related to that session) in service-side(without a method call) from WCF client. According to the WCF instance management and lifetime model, the session and instance relationsthip is maintained internally and the possible means for you to explicitly end a session is accessing the OperationContext.Current.InstanceContext.ReleaseServiceInstance method. See the "Instance Deactivation" section in the following article:

    #Discover Mighty Instance Management Techniques For Developing WCF Apps
    http://msdn.microsoft.com/en-us/magazine/cc163590.aspx#S8

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Monday, August 10, 2009 10:40 AM