Sako73
Sako73

Reputation: 10137

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 activity, 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.

Upvotes: 1

Views: 315

Answers (1)

Tad Donaghe
Tad Donaghe

Reputation: 6588

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.

Upvotes: 1

Related Questions