Hi
Thanks for the quick Reply but Session_OnStart & Session_OnEnd events not get fired when i run my application even i tried with Session_Start & Session_End events these events are also not fired.
What has been suggested here to store a Session variable with the time that the user arrived at every time the user first visits your page.
Now the thing about this is that you never know on your sever when the user leaves the page. Sessions time out after 20 minutes (by default), so your Session_End event will be fired after 20 minutes (because it will time out)....but your user may have left the page well before this 20 minute time out happens.
Therefore, you'll have to write a bit of JavaScript that posts back to your server when the user leaves the page.
The JavaScript event:
window.beforeunload() = functionThatCallsMyASPXPage()
Fries every time your page begins to unload (don't use onunload because by that time you cannot send any more requests to the server). It is in here that you can make a quick Ajax call to your ASPX page to indicate that the user is leaving the page.
Please note that this fires Every Time The Page Unloads. This means that when the user performs a full page postback to your aspx page this event will fire. You will need to write a bit of JavaScript code and apply it every control that performs full page postbacks. This bit of JavaScript will set a boolean that indicates to the function assigned window.beforeunload() event not call the aspx to tell it that the user has left the page.
I probably wouldn't use Session for this problem. I would use cookies instead.
Hope this gets you pointed in the right direction.
-Frinny