Solved

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
7
249 Views
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.
0
Comment
Question by:goodk
  • 3
  • 2
  • 2
7 Comments
 
LVL 23

Assisted Solution

by:Michael74
Michael74 earned 200 total points
Comment Utility
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
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 300 total points
Comment Utility
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
 

Author Comment

by:goodk
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:goodk
Comment Utility
Oops, I really wanted to give credit to both the respondents.  Not sure how to correct it.
0
 
LVL 23

Expert Comment

by:Michael74
Comment Utility
@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
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
Simply "Request Attention" just below your original question.
0
 

Author Closing Comment

by:goodk
Comment Utility
thanks guys
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now