By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,007 Members | 979 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,007 IT Pros & Developers. It's quick & easy.

Storing data in ASP.NET

P: n/a
Jax
Say for example a user of my website makes a selection on the site and I want to store that value for use on a later page what is the best way to do that?
My only method at the moment that I know would be to create a static class and static variables inside of that. But if more then one person was using the page would they be using the same variables? Or do they get a version of the static class each?
I dont know, which is why I ask.

jax
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Jax,

You are right, if the class was static, then the whole application would
have access to those variables. The best way to store data is to use the
HttpSessionState type, which is exposed through the Page class through the
Session property. Also, it is exposed through the HttpContext class,
through the Session property on that class. The type has an indexer which
is a hashtable. You can place whatever keys/values you wish in there
(depending on how you are storing the values, if they are persisted to an
ASP session server, SQL server, or in memory).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Jax" <an*******@discussions.microsoft.com> wrote in message
news:81**********************************@microsof t.com...
Say for example a user of my website makes a selection on the site and I want to store that value for use on a later page what is the best way to do
that? My only method at the moment that I know would be to create a static class and static variables inside of that. But if more then one person was using
the page would they be using the same variables? Or do they get a version of
the static class each? I dont know, which is why I ask.

jax

Nov 15 '05 #2

P: n/a
Jax
Nicholas,

Thanks once more for the help, I think i'll use the Session.Keys collection to store the data. Sounds good.

Jax
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.