Accessing Web Services with Silverlighthttp://forums.silverlight.net//46.aspx/1?Accessing+Web+Services+with+SilverlightDiscussions about using WCF in Silverlight, accessing SOAP and REST web services, and using XML, JSON, RSS and Atom data.”Mon, 01 Jan 0001 00:00:00 -050046168522http://forums.silverlight.net//p/69833/168522.aspx/1?Calling+web+service+if+browser+window+is+closedCalling web service if browser window is closed <p>I need to track logged-in users.<br> So I need to call web service if user closes browser window by clicking in upper right corner in browser window.</p> <p>I tried code below.<br> Application_Exit code is executed but service in not called.<br> Maybe application is terminated before service call is executed.</p> <p>How to call web service if browser window is closed ?</p> <p>Andrus.</p> <p><br> public App()<br> {<br> &nbsp; this.Exit &#43;= this.Application_Exit;<br> }</p> <p><br> public void Application_Exit(object sender, EventArgs e)<br> {<br> &nbsp; StockServiceSoapClient service = AWServiceFactory.GetService();<br> &nbsp; // this method is not executed in served:<br> &nbsp; service.LogoutAsync();<br> }<br> </p> 2009-01-31T22:39:36-05:00168604http://forums.silverlight.net//p/69833/168604.aspx/1?Re+Calling+web+service+if+browser+window+is+closedRe: Calling web service if browser window is closed <p>check this post: <a href="http://silverlight.net/forums/p/20279/130230.aspx">http://silverlight.net/forums/p/20279/130230.aspx</a></p> <p>I also tried like you but its not supported.</p> 2009-02-01T06:22:25-05:00168622http://forums.silverlight.net//p/69833/168622.aspx/1?Re+Calling+web+service+if+browser+window+is+closedRe: Calling web service if browser window is closed <p>If it possible to add some sleep call to allow async call to be completed ?</p> <p>Or is it possible to send some sync notification like http GET request to server ?</p> 2009-02-01T08:59:38-05:00168624http://forums.silverlight.net//p/69833/168624.aspx/1?Re+Calling+web+service+if+browser+window+is+closedRe: Calling web service if browser window is closed <p>&nbsp;Hi,</p> <p>This is difficult to acheive and may not even be possible. </p> <p>I've had a play around, and unfortunely even with Synchronous web services it just wont work!</p> <p>The unload event fires nicely in the browser and is passed to Silverlight (after you subscrive to it using hte HTML DOM Bridge)... This happens on the UI thread. As soon as the method that the JS calls in to reutrns, the browser cuts you off (kills the app).&nbsp;</p> <p>You'd think it would be easy to just make that method never return until the service call has completed, but the problem is that the service call happens on the UI thread also, so if you block the UI thread so it doesn't reutrn form the unload method call too early then the service will never run anyway.</p> <p>&nbsp;It's a catch 22 situation :)</p> <p>Cheers,</p> <p>Jordan. <br> </p> 2009-02-01T09:07:45-05:00168974http://forums.silverlight.net//p/69833/168974.aspx/1?Re+Calling+web+service+if+browser+window+is+closedRe: Calling web service if browser window is closed <p>&nbsp;Have you tried to make sync call in other thread in Exit event ?</p> <p>Have you tried to make xmlhttp or sync call from javascript unload event ?</p> <p>Andrus.</p> 2009-02-02T12:41:46-05:00169188http://forums.silverlight.net//p/69833/169188.aspx/1?Re+Calling+web+service+if+browser+window+is+closedRe: Calling web service if browser window is closed <p>&nbsp;Hi,</p> <p>No matter what thread you begin the request on, the network call happens on the UI thread (uses the browsers networking stack and what not, so it makes sense). The wait APM stuff blocks the UI thread. So either you can block UI thread indefinitely or you have to let the exit method exit and that causes the browser to exit anyway.</p> <p>Cheers, <br> </p> <p>&nbsp;Jordan. <br> </p> 2009-02-02T21:44:47-05:00188267http://forums.silverlight.net//p/69833/188267.aspx/1?Re+Calling+web+service+if+browser+window+is+closedRe: Calling web service if browser window is closed <p>You call the Web Service Method from javscript using XMLHTTP Request.</p> <p>This method can be called in body unload event.</p> 2009-03-15T06:49:03-04:00518519http://forums.silverlight.net//p/69833/518519.aspx/1?Re+Calling+web+service+if+browser+window+is+closedRe: Calling web service if browser window is closed <p>Any updates to this issue..? :(</p> 2011-01-31T06:12:19-05:00518700http://forums.silverlight.net//p/69833/518700.aspx/1?Re+Calling+web+service+if+browser+window+is+closedRe: Calling web service if browser window is closed <p>I have small solution for you which i implemented in my project, which my might not be the optimize solution but something is better than nothing.</p> <p>if user closes browser window by clicking in upper right corner in browser window, show a message box using Javascript for taking confirmation with ok button, while user clicks the ok button, we will get the enough time to call the webservice.</p> <p>You can implement this or similar one<br> </p> 2011-01-31T12:45:06-05:00519037http://forums.silverlight.net//p/69833/519037.aspx/1?Re+Calling+web+service+if+browser+window+is+closedRe: Calling web service if browser window is closed <p>Hi Syed,</p> <p>In my case when user clicks close button a confirmation box will appear and if user clicks OK , need to save the unsaved data and close the application. But my application closes without waiting for the result of user click(obviously it is an async call).</p> <p>Any help will be greatly appreciated...</p> <p>--thanks,</p> <p>Afsal</p> <p>&nbsp;</p> 2011-02-01T08:16:52-05:00