My Mistake:
I created a static class for a particular project with the sole purpose of storing session data (user full name, user name). I could have stored the data in a session object, but I guess I wanted to try something different. When I deployed the project, I noticed that when multiple users logged into the site, the display name would be inconsistent. I couldn't figure out the reason for this until I had a discussion with a coworker (thanks Clark)
What I Learned:
A static class scope lasts as long as a process is running. Many threads can share an instance, so whenever a user would log in, the existing data would be overwritten by the person that just logged in. The user that logged in before the latest person that logged in would show a different name than their own. I should probably use static classes for development tools (like a utility class), not for storing session data. Good thing I didn't show a SS#. Lesson learned.
More reading:
http://forums.asp.net/t/1155328.aspx?Static+Varibale+scope+in+ASP+Net
I created a static class for a particular project with the sole purpose of storing session data (user full name, user name). I could have stored the data in a session object, but I guess I wanted to try something different. When I deployed the project, I noticed that when multiple users logged into the site, the display name would be inconsistent. I couldn't figure out the reason for this until I had a discussion with a coworker (thanks Clark)
What I Learned:
A static class scope lasts as long as a process is running. Many threads can share an instance, so whenever a user would log in, the existing data would be overwritten by the person that just logged in. The user that logged in before the latest person that logged in would show a different name than their own. I should probably use static classes for development tools (like a utility class), not for storing session data. Good thing I didn't show a SS#. Lesson learned.
More reading:
http://forums.asp.net/t/1155328.aspx?Static+Varibale+scope+in+ASP+Net
Comments
Post a Comment