views:

113

answers:

2

Hello everyone,

I am developing using VSTS 2008 + C# + .Net 3.5 to develop ASP.Net application. At client side, in order to keep session live, I will refresh server for every 5 seconds. Here is my code at client side, server side Default.aspx will do nothing -- for the only purpose to keep client alive.

<html>
<head>
<meta http-equiv="refresh" content="10" />
<iframe src="http://localhost:20000/Default.aspx" width="1" height="1" />
</head>
<body />
<html>

I have monitored the traffic and found each time client will send a couple of headers to server side. Any ideas to reduce server load or traffic? If the # of clients are big, I am afraid the server workload will be increased significantly.

Here is the request and response header I monitored,

Request headers Connection : Keep-Alive Accept : / Accept-Encoding : gzip, deflate Accept-Language : en-us Host : localhost:20000 User-Agent : Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; InfoPath.2; .NET CLR 3.5.21022; CIBA; .NET CLR 3.5.30729; MS-RTC LM 8; .NET CLR 3.0.30729; OfficeLiveConnector.1.4; OfficeLivePatch.1.3)

Response headers Server : Microsoft-IIS/7.0

thanks in advance, George

+2  A: 

First question is: Why on earth do you think you have to keep the client alive?? What's the purpose of that??

Marc

marc_s
Hi Marc, I am keeping a very short session live timeout because the web application contains some important data and I want to avoid issues when user forget to logout, and another hacker comes to use his/her computer to use previous user's session information to do some hacking things.
George2
+2  A: 

If you're going to keep the session alive manually anyways you'll end up with those same problems and the kind of problems you're now trying to solve.

If you really really wanna try and make your application harder to hack based on session information (which most web banks see no reason to do other than to force a locout after like 10 min) you could reverse the logic. Have the server notify the client that the session will be terminated if the client replies the termination can be cancelled. (this can be done in JavaScript client side so if the browser has been closed there'll be no reply)

Rune FS
Thanks Rune, 1. another related question, how to set Session Timeout shorter than 1 minute? I found Session.Timeout property could only set session timeout in the basis of minute, so I can only set 1 minute as the minimal itme. 2. I would like to follow your points to implement Java script based solution, any reference code?
George2
@George for the JavaScript part what you'd have to do is to make a call from the web page to the server, that call needs to have a long timeout. When the server needs to terminate it will then reply to the request sent from the page when it loaded
Rune FS
But I do really suggest to rethink if it's really worth the trouble even web banks don't go that far to protect them self from session hijacking due to some one not logging out.
Rune FS
@George2: You can't set the session timeout shorter than one minute.
Guffa
Hi Guffa, I am surprised to learn that. :-)Do you have any documents to prove it?
George2
@Rune, do you have any Java script code to make reference?
George2