HTTP STATELESS..
-
Hi friends, If I am making my some member variable of a class as a static(say int i),then at each Page Postback i m able to manipulate(say increment) the previous value of i.My Question is whether by making member as a static are we making it to be remember by server during subsequent page requests..if so then how http is stateless.. Warm Regards, Rahul Agarwal
-
Hi friends, If I am making my some member variable of a class as a static(say int i),then at each Page Postback i m able to manipulate(say increment) the previous value of i.My Question is whether by making member as a static are we making it to be remember by server during subsequent page requests..if so then how http is stateless.. Warm Regards, Rahul Agarwal
Hi, Remember that static members belongs to a class. Therefore whatever you do to it in a class will be remembered for the time that this application is running in it's own session (will not influence another user). But the problem is it will be reset when the application close. Regards, Elizma
-
Hi, Remember that static members belongs to a class. Therefore whatever you do to it in a class will be remembered for the time that this application is running in it's own session (will not influence another user). But the problem is it will be reset when the application close. Regards, Elizma
Thanks..But I tried something like this.. static int i; protected void Page_Load(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e) { i=i+1; TextBox1.Text=i.ToString(); } For each Button Click event, the value of "i" is incremented and displayed in the TextBox. I have clicked the button 5 times and the text box shows 5 in it. At this moment,when I opened another browse , copy - paste the same url and I tried to click the button, it shows "6" in it. Then why it working when i am opening the page in new browser window..My question is whether making it static will make it remember at server during subsequent page postbacks or not? Warm Regards, Rahul
-
Thanks..But I tried something like this.. static int i; protected void Page_Load(object sender, EventArgs e){}protected void Button1_Click(object sender, EventArgs e) { i=i+1; TextBox1.Text=i.ToString(); } For each Button Click event, the value of "i" is incremented and displayed in the TextBox. I have clicked the button 5 times and the text box shows 5 in it. At this moment,when I opened another browse , copy - paste the same url and I tried to click the button, it shows "6" in it. Then why it working when i am opening the page in new browser window..My question is whether making it static will make it remember at server during subsequent page postbacks or not? Warm Regards, Rahul
according to me value of static variables is maintained at server till that variable is not assigned null value or u need to call the destructor to relase the memory occupied by that variable.Else server will maintain the varaibles value even if u close the application from client end.
-
Hi friends, If I am making my some member variable of a class as a static(say int i),then at each Page Postback i m able to manipulate(say increment) the previous value of i.My Question is whether by making member as a static are we making it to be remember by server during subsequent page requests..if so then how http is stateless.. Warm Regards, Rahul Agarwal
-
-
Thanks for answer..so static variable will be maintained at server during subsequent page requests..right?
That's right.
SG