简体   繁体   中英

How can I configure session in my WCF service called from windows phone 7?

I have a service which is being called from WP7. I know WP7(Silverlight) only supports basicHtptBinding till today and unfortunately it doesn't support Session so I can't use InstanceContextMode.PerSession and SessionMode.Required in this service. But I have some data on server which I need to be preserve it on session basis. What options do I have?

I'm not familiar with Windows Phone 7 programming, but if it will allow you to use basicHTTPContextBinding, which is a flavor of basicHTTPBinding, then I suggest you look into a Durable Service.

Durable services allow you to save session state in some persistent storage and access it with each new method call via a token.

Take a look at the blog article at this link .

Even if you can't create a formal Durable service, you may be able to create something with a similar idea - pass a token (login/userid or something) and read state from persistent storage - database table or something.

Let us know if you get it working!

You could use a ConcurrentDictionary in a static class on the server-side to cache the object using the user's identity as a key. If you need the cache around for a very long time, you'll want to host the service in a Windows Service, to avoid issues with app pool cycling, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM