How can I initialize session variables in asp.net when I start the application? All of them without knowing their names in particular.

How can I initialize session variables in asp.net when I start the application?  All of them without knowing their names in particular.
goodkAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
käµfm³d 👽Connect With a Mentor Commented:
How can I initialize session variables in asp.net when I start the application?
And how would you expect that to happen? No one is actually using your application at the time it is started by IIS, so there is no session. A session only exists when a user begins interacting with your application. So is what you are asking how to have a default value for a particular set of session values?
0
 
Michael FowlerConnect With a Mentor Solutions ConsultantCommented:
If you are looking to loop through the session variables you could use

SessionStateItemCollection items = new SessionStateItemCollection();
foreach (string s in items.Keys)
{
// Do something
}

Open in new window


For some more information on session variables have a look at this MSDN page
https://msdn.microsoft.com/en-us/library/ms178581(v=vs.140).aspx
0
 
goodkAuthor Commented:
Thank you guys.  I think I have a deeper problem to solve as some session variables are initialized and another web page tries to use them without being set for that particular web page.  

Not really sure how to address the situation.  Maybe I need to append the page name into the session variable name.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
goodkAuthor Commented:
Oops, I really wanted to give credit to both the respondents.  Not sure how to correct it.
0
 
Michael FowlerSolutions ConsultantCommented:
@Goodk

Don't worry about it, but for interests sake you may want want to have a quick look at the EE help page which has some information on how to accept questions and changing your decision
http://support.experts-exchange.com/customer/portal/articles/608621-how-do-i-accept-a-comment-as-my-solution-
0
 
käµfm³d 👽Commented:
Simply "Request Attention" just below your original question.
0
 
goodkAuthor Commented:
thanks guys
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.