How can Site.Master access a variable created by Global.asax?

I have a variable I'd like to create in the Global.asax file that I then want to access from the Site.Master file.  How can I do that?  

Thanks,
newbieweb
newbiewebSr. Software EngineerAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
newbiewebConnect With a Mentor Sr. Software EngineerAuthor Commented:
So this threw an exception:
HttpContext.Current.Session.Add(Key, Value)

So, I ended up using:

Context.Items["mySessionVar"] = mySessionVar;

But you got me close.
0
 
Paul JacksonConnect With a Mentor Software EngineerCommented:
Use a Session variable.

In global.asax sun Session_Start or Application_Start depending on whether you want the value to be unique to the user session or the application as a whole.

Sesssion("mySessionVar") = 'valuetobestored'

Then access it on the master page :

Session("mySessionVar")
0
 
newbiewebSr. Software EngineerAuthor Commented:
I get this exception:
"Session state is not available in this context." when I try this first step...

            Session["RDDBAdminDataStore"] = rddbAdminDataStore;
            Session["AppPermissions"] = appPermissions;


Do I first need to create a Session variable?
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
Paul JacksonConnect With a Mentor Software EngineerCommented:
Try

HttpContext.Current.Session.Add(Key, Value)
0
 
newbiewebSr. Software EngineerAuthor Commented:
Both the

Context.Session

and the

HttpContext.Current.Session

are null in Global.Application_Start()
0
 
newbiewebSr. Software EngineerAuthor Commented:
Thanks.
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.