global variables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tina

    #1

    global variables

    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.myvaria ble
    Thanks,
    T


  • Mark Fitzpatrick

    #2
    Re: global variables

    If you want the same variable across the application, you use Application
    variables and create them in the application_sta rt event. If you need them
    individually for each session then you use session variables. You don't
    reference them assession.myvar iable, 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" <tinamseaburn@e xcite.com> wrote in message
    news:u87uHnSWDH A.2040@TK2MSFTN GP11.phx.gbl...[color=blue]
    > 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[/color]
    past[color=blue]
    > 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[/color]
    I[color=blue]
    > can't seem to reference them with session.myvaria ble
    > Thanks,
    > T
    >
    >[/color]


    Comment

    Working...