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
252 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
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
https://msdn.microsoft.com/en-us/library/ms178581(v=vs.140).aspx
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 300 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?
0
 

Author Comment

by:goodk
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.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

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

Expert Comment

by:Michael74
ID: 40584893
@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 75

Expert Comment

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

Author Closing Comment

by:goodk
ID: 40608435
thanks guys
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

861 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

29 Experts available now in Live!

Get 1:1 Help Now