locked
How To implement Session Based WCF Service with Silvelight 4 RRS feed

  • Question

  • Does SIlverlight support wshttpbinding for WCF ?

    How Can I Implement Session Based WCF Service with Silverlight 4?

    Saturday, July 30, 2011 6:54 AM

Answers

  • I found the solution I Implement a new Session class at Wcf Level to achieve this

      public class WCFSession
        {
                   private string _userName;

            public string UserName
            {
                get { return _userName; }
                set { _userName = value; }
            }

            private DateTime _lastCallTime;

            public DateTime LastCallTime
            {
                get { return _lastCallTime; }
                set { _lastCallTime = value; }
            }

            private DateTime _connectionTime;

            public DateTime ConnectionTime
            {
                get { return _connectionTime; }
                set { _connectionTime = value; }
            }

           i use Username as Key in this approach
            
        }

    Monday, August 15, 2011 4:26 AM

All replies

  • Hi Shoaib,

    WSHttpBinding is not compatible with Silverlight.

    And WCF session is not supported in BasicHttpBinding which is required by Silverlight.

    But you can use ASP.Net session.

    For how to use ASP.Net session, please refer to

    http://www.eggheadcafe.com/tutorials/aspnet/c72cc77a-bf84-4180-a35b-46b8726ab782/using-aspnet-session-with-silverlight-and-wcf-services.aspx

     

    Best Regards,

     

     

    Friday, August 5, 2011 5:49 AM
  • Hi Shi Ding

     

    I just want to implement one service instance per user is there any approach to get this. 

    Monday, August 8, 2011 5:03 AM
  • Shoaib,

    To achieve that you can use InstanceContextMode.Single option for service behavior. For e.g. if you have a service named 'Myservice' then following is how you'll have to specify ServiceBehvior attribute. 

    [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
    public class MyService
    {...

    Please mark it as answer if it helps. Thanks.

    Regards,

    Omer Javed

    Monday, August 8, 2011 5:23 AM
  • Omer I mean One Instance Per user  you advised me for Sigelton Instance . I need when any new user intitiate Service call a New Instance should be made per User and it souhld persist with the life of user logged in.

    Tuesday, August 9, 2011 3:31 AM
  • Sorry for the mistake.  There are three settings for InstanceContextMode :  Single, PerSession, PerCall. I think what you need is InstanceContextMode.PerSession setting.  Thanks.

     

    Regards,

    Omer Javed

     

     

     

    Tuesday, August 9, 2011 3:49 AM
  • I found the solution I Implement a new Session class at Wcf Level to achieve this

      public class WCFSession
        {
                   private string _userName;

            public string UserName
            {
                get { return _userName; }
                set { _userName = value; }
            }

            private DateTime _lastCallTime;

            public DateTime LastCallTime
            {
                get { return _lastCallTime; }
                set { _lastCallTime = value; }
            }

            private DateTime _connectionTime;

            public DateTime ConnectionTime
            {
                get { return _connectionTime; }
                set { _connectionTime = value; }
            }

           i use Username as Key in this approach
            
        }

    Monday, August 15, 2011 4:26 AM