ASP.NET Application state vs a Static object
if i have a standard ASP.NET application, is there any difference between making an object static as opposed to putting the object instance in the Application state?
if i have a standard ASP.NET application, is there any difference between making an object static as opposed to putting the object instance in the Application state?
So far I’ve been using Session to pass some variables from one page to another. For instance user role. When a user logs in to the web application the role id of the user is kept in Session and that role is checked at different parts of the application. I’ve recently started thinking why not use static members instead. I can store the same information in a static field and easily access it anywhere in my application (well anywhere the namespace in which that static field resides is included.) I know that using Session variables comes handy sometimes, such that:
Say you want to share some resource, like a class or a variable across all threads/sessions within a ASP.NET web application. What is better?
Can I use static variables in my web application ? what are the alternatives to static ? When I use static variables in pages and more than one user use the application, it makes conflict data (incorrect data).