Solved

Why not Request.IsClientConnected?

Posted on 2004-09-19
7
975 Views
Last Modified: 2011-10-03
Hi Experts,

I have seen following code in a few tutorials
If response.IsClientConnected=true then
but there is not good explanation for that and I got questions:
1. What does disconnected mean?
2. Is a client a session?
3. If we got a few client, when we know response.IsClientConnected = true, how to know which session/client is connected?
4. Why not Request.IsClientConnected?
0
Comment
Question by:daveask
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 14

Assisted Solution

by:huji
huji earned 70 total points
ID: 12095971
As far as I know, there are some cases in which the client is disconnected (for example by closing the browser window) but the server does not sense it. That is, the server continues processing the codes which takes resources and time. So for huge processings you can ensure the client to be still connected by that piece of code, and stop the rest of the code, if he is disconnected.
An example is, you can put some lines in golbal.asa file under Session_OnEnd function, and hope that they are run when the client disconnects from your site, any way, but in reality, this may be done only sometimes.

Wish I can help
Huji
0
 

Author Comment

by:daveask
ID: 12096569
Thank you.
So,
1. the server cannot accurately know when the client disconnects,
2. the server can delect if a client still disconnected or not by send something to the client, that is why it uses response instead of request,
3. put response.IsClientConnected in Session_OnEnd function so that after a session timeout interval we know this session(client) is really disconnected or not,
4. it is no use to put response.IsClientConnected in another places (other than Session_OnEnd or Session_OnStart), because we wont know which client we are checking.

Am I right?
0
 
LVL 14

Expert Comment

by:huji
ID: 12099550
Part 1 and 2 are correct.
Part 3 is not. Session_OnEnd is run when the server knows that the client is disconnected, so untill it does not know that, it will not run that function, and IsClientConnected is not called.
Part 4 is not correct again. You can use IsClientConnected in many other places, and I give you an example:
When a user makes arequest which needs lots of processing and connecting to several databases (which may take as much as 20 seconds on your server for example), you can check if he is still connected, in the middle of the processing code; if not, you can simply cancel the rest of the processing to free some CPU for other online users.
Wish I can help
Huji
0
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

Author Comment

by:daveask
ID: 12100293
Thank you and I am glad that I got two of four are correct :)

>Session_OnEnd is run when the server knows that the client is disconnected
It seems to me that Session_OnEnd is fired when timeout instead when the client closes his browser!

>You can use IsClientConnected in many other places
If we have a few clients, when we find response.IsClientConnected = False, how to know which client disconnected?
0
 
LVL 14

Expert Comment

by:huji
ID: 12100758
No. The session is ended when it is ENDED any ways! You specify session timeout as 30 minutes, and it means that if the user has his window open and remains idle (no clicks, no other types of reconnection to your server) then the session is ended after 30 minutes, but if the user refreshes the page 29 miinutes 55 seconds after the last connection to your site, the session is renewed again, and another 30 minutes will be needed for OnEnd to happen.
Passing the timout is only one way to finish sessions. Another situation is when the server understands that the user has closed the browser window related to that session number, but this is not detected by servers as often as it happens.
Second and more iportant point: when Reponse.IsClientConnected is Flase, it means that THIS session is disconnected! and the ID of this session variable is stored in Session.SessionID (read-only) property. You can not know which username in your database is disconnected, unless you store the sessionID when the user is authenticated in the database.
Don't hesitate to ask questions.
Wish I can help
Huji
0
 
LVL 15

Accepted Solution

by:
joeposter649 earned 30 total points
ID: 12102893
I think huji covered a lot here but you should realize that, just like the rest of the response methods, IsClientConnected can only be used once the browser requests a page.  Nothing in asp can initiate contact with the client.

This link might help too.
http://devguru.com/Technologies/asp/quickref/response_isclientconnect.html
0
 
LVL 14

Expert Comment

by:huji
ID: 12103551
Well joeposter649 noted a good point. As IsClientConnected is a reposnse method, it can only be called when a RESPONSE is being made. So you can call it several times after a response STARTs and before it is ENDed.
I suppose that your question is answered, am I right daveask?

Wish I can help
Huji
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question