By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,853 Members | 1,570 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,853 IT Pros & Developers. It's quick & easy.

global variables

P: n/a
I would like to know the preferred way in which to define, store, and
retrieve global varialbes in asp.net applications. I have read through past
threads here and have seen mixed advice. Some say to define them in
global.asax but I can't seem to reference them. Others say that they must
be defined in the session_start and that they cannot be simply defined in
global.asax. Yet others say just put them in any class anywhere and
reference them.

It seems the right answer would be defining them as session variables but I
can't seem to reference them with session.myvariable
Thanks,
T
Nov 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
If you want the same variable across the application, you use Application
variables and create them in the application_start event. If you need them
individually for each session then you use session variables. You don't
reference them assession.myvariable, it is actually a collection so you
would reference them (in C#) as session["myvariable"]. Just remember that
these are kept in server memory so if you have lots of sessions this can be
a performance drag.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Tina" <ti**********@excite.com> wrote in message
news:u8**************@TK2MSFTNGP11.phx.gbl...
I would like to know the preferred way in which to define, store, and
retrieve global varialbes in asp.net applications. I have read through past threads here and have seen mixed advice. Some say to define them in
global.asax but I can't seem to reference them. Others say that they must
be defined in the session_start and that they cannot be simply defined in
global.asax. Yet others say just put them in any class anywhere and
reference them.

It seems the right answer would be defining them as session variables but I can't seem to reference them with session.myvariable
Thanks,
T

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.