开发者

How to detect when connection to server is closed in silverlight 3

I have a Silverlight 3 application. It accesses WCF services that run on IIS. If I let the application sit for a while with no activi开发者_JAVA技巧ty, it appears that I lose my connection to the server/login authentication, and my service calls fail.

It would appear that I am being logged out for security purposes, but this is not an area that I understand well. We are using a federated STS to create an encrypted token for security.

Can someone explain what is happening (if my description is clear enought), and how can I detect this event in my Silverlight application and redirect them back to the login page.

Thank you for any help.


How are you calling the WCF service? You want to make sure that you only create and open a connection to your proxy object just before you make any calls to the WCF service, and then immediately close the connection.

Don't make a connection at the beginning of your app and then close when you're done. That will needlessly keep the service in memory. If you need to have a long running service then I suggest looking into Durable WCF Services which will let you save state between method calls.

Generally you want to treat your services as stateless and connect just before you use a method and close right after. This way you won't need to worry about when your connection closes, etc.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜