<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>C#</title><link>http://forums.asp.net/37.aspx</link><description>Discussions/Questions about the C# language. &lt;a href="http://aspadvice.com/SignUp/list.aspx?l=13&amp;c=23" target="_blank"&gt;Email List&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Are Static Properties in Static Classes Safe?</title><link>http://forums.asp.net/thread/3273961.aspx</link><pubDate>Fri, 03 Jul 2009 19:42:49 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3273961</guid><dc:creator>JeffreyABecker</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3273961.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=37&amp;PostID=3273961</wfw:commentRss><description>&lt;p&gt;&lt;BLOCKQUOTE&gt;&lt;div&gt;&lt;img src="/Themes/fan/images/icon-quote.gif"&gt; &lt;strong&gt;ksome:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;It seems to me that it depends on how web applications are run.&amp;nbsp; Is the web app really a DLL that is called by IIS?&amp;nbsp; In this case, all users would share the same DLL and static variables so what I doing would be a problem.&amp;nbsp; If on the other hand, the web app is run like a real app - EXE - then each user&amp;#39;s instance of the app is a separate process and will have its own static properties.&lt;/div&gt;&lt;/BLOCKQUOTE&gt;&lt;/p&gt;&lt;p&gt;Your analysis is dead on.&amp;nbsp; It would be &amp;#39;safe&amp;#39; in a single user context, but not in a multi-user context.&amp;nbsp; Maybe you could set up some sort of cache which used methods instead?&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Are Static Properties in Static Classes Safe?</title><link>http://forums.asp.net/thread/3270637.aspx</link><pubDate>Thu, 02 Jul 2009 07:35:43 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3270637</guid><dc:creator>jimmy q</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3270637.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=37&amp;PostID=3270637</wfw:commentRss><description>&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;
A simple explanation is static is like global so any change will affect other users who are relying on this variable.&lt;/p&gt;&lt;p&gt;Static variables are loaded in the appdomain so all processes/threads within it share the same value.&lt;/p&gt;&lt;p&gt;If you are after a session specific container then use ASPNET Session object.&lt;/p&gt;&lt;p&gt;If you want to use it like a global field then you can use static but remember to make it threadsafe&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Are Static Properties in Static Classes Safe?</title><link>http://forums.asp.net/thread/3270618.aspx</link><pubDate>Thu, 02 Jul 2009 07:29:56 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3270618</guid><dc:creator>HeartattacK</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3270618.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=37&amp;PostID=3270618</wfw:commentRss><description>&lt;p&gt;DO NOT USE STATIC VARIABLES FOR USER SPECIFIC DATA.&lt;/p&gt;
&lt;p&gt;Your concern is very correct. Session is per user, static variables are not. Changing the static variable for one user will change it for all users.&amp;nbsp;&lt;/p&gt;</description></item><item><title>Are Static Properties in Static Classes Safe?</title><link>http://forums.asp.net/thread/3270599.aspx</link><pubDate>Thu, 02 Jul 2009 07:22:52 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3270599</guid><dc:creator>ksome</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3270599.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=37&amp;PostID=3270599</wfw:commentRss><description>&lt;p&gt;When my Page_Load event handler is called, I load Session data into static properties in a static class so that the rest of the classes in the app can have easy access to the data.&amp;nbsp; Is this safe to do when there will be multiple, concurrent users of the application?&lt;br /&gt;&lt;br /&gt;It seems to me that it depends on how web applications are run.&amp;nbsp; Is the web app really a DLL that is called by IIS?&amp;nbsp; In this case, all users would share the same DLL and static variables so what I doing would be a problem.&amp;nbsp; If on the other hand, the web app is run like a real app - EXE - then each user&amp;#39;s instance of the app is a separate process and will have its own static properties.&lt;br /&gt;&lt;br /&gt;Are one of these cases right?&amp;nbsp; If not, what is going on?&amp;nbsp; And, is it safe to use static properties?&lt;/p&gt;</description></item></channel></rss>