Reputation: 11
I'm old to VB but new to ASP.NET
I have written several dictionaries in new website. problem is that if multiple users are using these dictionaries at the same time, one user gets another user's information.
Being new to ASP.NET, what would the best way to get around this problem be? Session State or ViewState? Am I looking in teh wrong direction?
Upvotes: 1
Views: 877
Reputation: 13437
if you want to access data like User
information such as Name,LastName,... Session
is best choice bacause this data not change for current user. but if you want to store a value in a variable you should consider concurrency problem.for example if you have a page with a simple button and text box that after clicks on button text box value stored in Session
,if user open 2 instance of that page then there will be a session conflict.every button clicks over write session data. if you want store variable in a page you can use ViewState
but you should consider this value can see easily by user.and if you want to secure values you should use View State Encryption
. and if you want pass values between pages you can use Query String
Good Luck
Upvotes: 0
Reputation: 6123
Server Side:
Session is a user specific or you can say browser specific. It is not shared among all the users of a site. Session can hold any object data type.
Session["key"] = "value";
Application is shared across all the users on the site.
Application["key"] = "value";
Client Side:
ViewState data is not shared among users and even not among the pages. It retains the data during a post back.
ViewState["key"] = "value";
Upvotes: 2
Reputation: 710
Session will hold information that is particular to a user and last for the user's browsing session. ViewState will hold the information that is particular to the controls on the page that the user is currently browsing.
If you would like to store information that is specific to a user and needs to remain with them as they browse the site, Session is a fine solution for that.
Upvotes: 1