Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Why not Request.IsClientConnected?

Posted on 2004-09-19
7
Medium Priority
?
1,013 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 280 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 120 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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 would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

604 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