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

Posted on 2015-02-01
Medium Priority
Last Modified: 2015-02-13
How can I initialize session variables in asp.net when I start the application?  All of them without knowing their names in particular.
Question by:goodk
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
LVL 23

Assisted Solution

by:Michael Fowler
Michael Fowler earned 800 total points
ID: 40583294
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
LVL 75

Accepted Solution

käµfm³d   👽 earned 1200 total points
ID: 40583349
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?

Author Comment

ID: 40584743
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.
A new era in Cloud training has arrived.

A day that will go down in Cloud history.. But are you ready for it? Will you accept this Cloud challenge?


Author Comment

ID: 40584750
Oops, I really wanted to give credit to both the respondents.  Not sure how to correct it.
LVL 23

Expert Comment

by:Michael Fowler
ID: 40584893

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
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 40585219
Simply "Request Attention" just below your original question.

Author Closing Comment

ID: 40608435
thanks guys

Featured Post

How To Reduce Deployment Times With Pre-Baked AMIs

Even if we can't include all the files in the base image, we can sometimes include some of the larger files that we would otherwise have to download, and we can also sometimes remove the most time-consuming steps. This can help a lot with reducing deployment times.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question