Answered by:
Static Variable is not working properly in IIS

Question
-
I have a static variable in my page to set the visibility of controls. It is working fine while running in local. But not working while running in IIS. For ex:Based on the value of the static variable I am showing the controls. While running in local system, it is exactly showing one set of controls as variable value is one. But while running in IIS, it is showing two sets of controls. What should I do?
Can you please guide me in this???
- Moved by Mike Feng Monday, March 18, 2013 9:06 AM
Friday, March 15, 2013 6:06 AM
Answers
-
Maybe your application works on IIS in so-called “Web garden” or “Web farm” modes, when there are more than one web process, or even more web machines. The static variables are not shared by processes. Consider some other common places instead of static variables. For example put the values in database.
Sunday, March 17, 2013 9:13 AM -
Hi NithiKrish,
Please try this issue on IIS forum: http://forums.iis.net/
Best regards,
Mike Feng
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.Monday, March 18, 2013 9:06 AM
All replies
-
So it's showing two set of controls because value is two is that so?
Static variables in ASP.NET web page might be problematic as all instances access it, so it might be that you at some case write invalid value to it when there is multiple users and because of that it does not behave as in local machine where there usually is just one user for the web site.
- Edited by MasaSam Friday, March 15, 2013 2:27 PM
Friday, March 15, 2013 2:27 PM -
Maybe your application works on IIS in so-called “Web garden” or “Web farm” modes, when there are more than one web process, or even more web machines. The static variables are not shared by processes. Consider some other common places instead of static variables. For example put the values in database.
Sunday, March 17, 2013 9:13 AM -
K MasaSam. What Should I do now? Should I change my code or IIS. Shall I initialize the static variable in !Ispostback?Monday, March 18, 2013 4:50 AM
-
Ok Viorel. I will try that.Monday, March 18, 2013 4:51 AM
-
Hi NithiKrish,
Please try this issue on IIS forum: http://forums.iis.net/
Best regards,
Mike Feng
MSDN Community Support | Feedback to us
Develop and promote your apps in Windows Store
Please remember to mark the replies as answers if they help and unmark them if they provide no help.Monday, March 18, 2013 9:06 AM