Server side operation from javascript

  • Thread starter Thread starter RJN
  • Start date Start date
R

RJN

Hi

I want to do some server side operation on close of a browser. I created
a server side html button and invoked a post back event on close of
browser something like
__doPostBack('btnUnlock',''); What I realised this is unreliable as the
operation is yet not completed when the browser has closed and
essentially the thread would have been killed. Is there any way in
javascript wherein I post a message to the server, wait for the response
and then the window closes something like send message and wait for the
response.

Regards

RJN
 
RJN said:
Is there any way in
javascript wherein I post a message to the server, wait for the response
and then the window closes something like send message and wait for the
response.

There is no way to ensure this will fire. Client side javascript can be
disabled or stopped in many ways.

Instead, use the Session End event handler in the Global.asax.
 
Yes, there is a very simple way. Post your message (it doesn't have to be
hacker style _doPostBack, it can be any value passed to the server in one of
legal and documented ways) and, in the response, get server-side to emit
window.close() javascript statement.

Eliyahu
 
Back
Top