static variable in a namespace
-
Hi all, I want to know is there any difference in the functioning of static variables defined inside a class library to that defined in a codebehind class. I came across such a situation when both of these are working differently.The codebehind one maintains single copy for all instance of that page and changes made at 1 place are being reflected in all the other places. where as the class library's one doesn't reflect the change smade to it except for the MOzilla browser. Is there somebody already faced and foud the solution to this problem.Please be kind enough to tell me answer. Thank you
-
Hi all, I want to know is there any difference in the functioning of static variables defined inside a class library to that defined in a codebehind class. I came across such a situation when both of these are working differently.The codebehind one maintains single copy for all instance of that page and changes made at 1 place are being reflected in all the other places. where as the class library's one doesn't reflect the change smade to it except for the MOzilla browser. Is there somebody already faced and foud the solution to this problem.Please be kind enough to tell me answer. Thank you
Static variables stay in memory until the application domain where it is hosted unloads. So the static variables declared in a code behind file and a separate class library should work similarly. Is this library creates a new app domain?
joindotnet wrote:
where as the class library's one doesn't reflect the change smade to it except for the MOzilla browser.
Browsers don't have any role in this. static variables are kept on servers memory and managed by the runtime. Make sure your ASP.NET process is not recycling frequently.
Navaneeth How to use google | Ask smart questions
-
Static variables stay in memory until the application domain where it is hosted unloads. So the static variables declared in a code behind file and a separate class library should work similarly. Is this library creates a new app domain?
joindotnet wrote:
where as the class library's one doesn't reflect the change smade to it except for the MOzilla browser.
Browsers don't have any role in this. static variables are kept on servers memory and managed by the runtime. Make sure your ASP.NET process is not recycling frequently.
Navaneeth How to use google | Ask smart questions
Hi thanks for replying.Could u plz tell me why changes I make to the static variable are not reflected on IE but reflected on Mozilla??? I am confused.
-
Hi thanks for replying.Could u plz tell me why changes I make to the static variable are not reflected on IE but reflected on Mozilla??? I am confused.
joindotnet wrote:
Could u plz tell me why changes I make to the static variable are not reflected on IE but reflected on Mozilla???
I don't know. Have you tried pressing Ctrl + F5? Sometime IE's cache will be making problem.
Navaneeth How to use google | Ask smart questions
-
Hi thanks for replying.Could u plz tell me why changes I make to the static variable are not reflected on IE but reflected on Mozilla??? I am confused.
As the browser has nothing to do with how the static variable is stored, you are looking for the problem in the wrong place. The variable is changed just fine, it's just that you don't see the current value in the browser, probably because you are looking at a cached page.
Despite everything, the person most likely to be fooling you next is yourself.
-
As the browser has nothing to do with how the static variable is stored, you are looking for the problem in the wrong place. The variable is changed just fine, it's just that you don't see the current value in the browser, probably because you are looking at a cached page.
Despite everything, the person most likely to be fooling you next is yourself.
Hi Guffa, Thanks for bothering.But I have set my browser to refresh every time a page is requested.It never sees the cached value....What might be the problem here I don't understand. Has this something to do with dll and AppDomain???'coz 1 variable is defined in the dll,other 1 is in normal codebehind.
-
Hi Guffa, Thanks for bothering.But I have set my browser to refresh every time a page is requested.It never sees the cached value....What might be the problem here I don't understand. Has this something to do with dll and AppDomain???'coz 1 variable is defined in the dll,other 1 is in normal codebehind.
A static variable is a static variable regardless of where in the application it is. There is only one instance of each static variable in the application, shared between all threads. If you change the value in a static variable and don't see the change, it's because you are not reading the variable at all. Static variables are usually not useful in a web application, as it's a multi threaded application, and all threads share the same static variable. If one user changes the variable, all users see the change.
Despite everything, the person most likely to be fooling you next is yourself.