ASP.NET 2.0 static variables in Global.asax

Discussion in 'ASP .Net' started by drasko, Sep 8, 2006.

  1. drasko

    drasko Guest

    In Microsoft Knowledge base, Article ID: 312607 says:
    "It is recommended that you store data in static members of the
    application class instead of in the Application object."

    Does this apply for ASP.NET 2.0? If it does, how can I accomplish this?
    I am using c#...

    Thanx in advance,

    Drasko
     
    drasko, Sep 8, 2006
    #1
    1. Advertising

  2. drasko

    Tim_Mac Guest

    hi drasko,
    in .net 2, i would put the static variable anywhere in App_Code.
    e.g.
    public class Util
    {
    public static string Whatever = "Hello";

    then anywhere in your site you can use Util.Whatever to access the string,
    it will be the same across all sessions and instances of the application.

    good luck
    tim



    "drasko" <> wrote in message
    news:...
    > In Microsoft Knowledge base, Article ID: 312607 says:
    > "It is recommended that you store data in static members of the
    > application class instead of in the Application object."
    >
    > Does this apply for ASP.NET 2.0? If it does, how can I accomplish this?
    > I am using c#...
    >
    > Thanx in advance,
    >
    > Drasko
    >
     
    Tim_Mac, Sep 8, 2006
    #2
    1. Advertising

  3. drasko

    drasko Guest

    Hi, Tim!

    That's the real answer for my question.

    Thanx,
    Drasko
     
    drasko, Sep 11, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VSK
    Replies:
    1
    Views:
    790
    Alvin Bruney
    Jul 29, 2003
  2. Daniel Bass
    Replies:
    2
    Views:
    6,883
    Daniel Bass
    Dec 31, 2003
  3. =?Utf-8?B?YmNoYXJsZXM=?=

    global.asax and global.asax.cs

    =?Utf-8?B?YmNoYXJsZXM=?=, Oct 4, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    841
    =?Utf-8?B?YmNoYXJsZXM=?=
    Oct 5, 2004
  4. Sahil Malik [MVP]

    static variables in global.asax

    Sahil Malik [MVP], Nov 13, 2005, in forum: ASP .Net
    Replies:
    25
    Views:
    4,466
    Scott Allen
    Nov 15, 2005
  5. Mark Rae

    Global.asax / Global.asax.cs in v2

    Mark Rae, May 23, 2006, in forum: ASP .Net
    Replies:
    6
    Views:
    3,165
    Mark Rae
    May 23, 2006
Loading...

Share This Page