I have WCF server and Silverlight client using pollingDuplexHttpBinding binding .
I wanna close the connection and call the EndSession operation method , which clears the user from
active users list, and close the session ( IsTerminating = true )
[OperationContract(IsOneWay = true, IsInitiating = false, IsTerminating = true)]
void EndSession();
according to this , you can't call on wcf operation on Application_Exit event , it also gives a
solution which seems "2 much noisy" to me ,
What's my options here? Is this the only way?
1) Using the link solution?
2) Server running a method every X seconds to check duplex object state is alive?
(((ICommunicationObject)clientContract.Value).State != CommunicationState.Opened
3) Other ?! Easy built-in solution ? Why Silverlight is HELL ?!
This is the solution which I just tried out and which works. Its core was posted in the comments in the link from your question! :)
Silverlight
App.Exitevent:The above code sends a request to the page that hosts the Silverlight object, which is an ASPX page and has the following code-behind:
chatSvcshould, obviously, be a reference to your service andQuitwhatever method you want to call whenever a client closes. You can pass required parameters via query string.It's not pretty, I admit, but it does work.
EDIT: The reason I'm not using
DocumentUridirectly, is because I'm using the navigation framework for my Silverlight application.