1
Answer

About application memory

satish babu

satish babu

12y
1.2k
1
Hi friends,i have small doubt on application memory.I wrote the code in global.asax file as
 
public void application_start(....)
{
application["n"]=0;//initialization of variable
}
public void session_start(......)
{
application["n"]=(int)application["n"]+1;//for every time browser start incrementing the session variable
}
public void session_end(....)
{
application["n"]=(int)application["n"]-1;//decrementing the session when the session abandon
}

in default.aspx page
page_load(....)
{
response.write("number of users:"+application["n"].tostring());
}

in logout.aspx
i am taking an logout button
for the button click
protected void button1_click(.....)
{
session["n"].abandon();
}

when the user opens browser with default.aspx page he will see number of users opens his application

when the user clicks on logout button decrement the users from application memory.

It's working correctly but it increments only until to 2 and from 3rd request onwards it again starts from application_start() event.I cannot find the error where it is

can any one tell me the problem?





Answers (1)