Static Variables and Craziness

Discussion in 'ASP .Net' started by dougloj, Jan 5, 2007.

  1. dougloj

    dougloj Guest

    Howdy.

    I have an ASP.NET application written in C#. I know this sounds nuts,
    but instead of having multiple .aspx files to display various parts of
    the Web site, I do almost everything on my default.aspx page. Instead
    of redirecting to various .aspx files, I change the Visible attribute
    of various asp.tables to True and False to change the display. Yes, my
    default.aspx and default.aspx.cs files are HUGE.

    I have found out that when two sessions of my ASP.NET application are
    running on the same server, variables from one session are taking on
    values from variables in the other session.

    The reason that variable values are getting mixed up between the
    sessions may be because I use static variables. I thought the static
    variables would automatically be independent between sessions. Does my
    use of static variables seem like it may be causing the variable mix
    up? Does anybody know if there is a way to correct the problem? Is
    there anything in the server configuration or Web.config file to fix
    the problem? Should I change my static variables to session variables?

    I know I should restructure my stuff to use individual .aspx files. If
    anybody has ANY ideas as to what I can do in the interim, I'd GREATLY
    appreciate hearing your thoughts.
     
    dougloj, Jan 5, 2007
    #1
    1. Advertising

  2. dougloj

    TiSch Guest

    Re: Static Variables and Craziness

    Hello,

    static (shared in vb.net) are shared between all instances of the
    application(sessions).
    If you want individual values you need another way to save them. You
    could use Session or ViewState for this purpose. What are you saving in
    the variables?

    Regards,
    Tim
     
    TiSch, Jan 5, 2007
    #2
    1. Advertising

  3. dougloj

    Hans Kesting Guest

    Re: Static Variables and Craziness

    > Hello,
    >
    > static (shared in vb.net) are shared between all instances of the
    > application(sessions).
    > If you want individual values you need another way to save them. You
    > could use Session or ViewState for this purpose. What are you saving in
    > the variables?
    >
    > Regards,
    > Tim


    Not quite, but the result (and the solution) is the same.
    There is just a single instance of the web-application, which serves
    multiple sessions concurrently. So a static variable is shared between
    all sessions.

    Hans Kesting
     
    Hans Kesting, Jan 5, 2007
    #3
  4. dougloj

    dougloj Guest

    Re: Static Variables and Craziness

    I mainly save user account info, product info and order info in objects
    of my own class types. These objects are static.

    TiSch wrote:
    > Hello,
    >
    > static (shared in vb.net) are shared between all instances of the
    > application(sessions).
    > If you want individual values you need another way to save them. You
    > could use Session or ViewState for this purpose. What are you saving in
    > the variables?
    >
    > Regards,
    > Tim
     
    dougloj, Jan 5, 2007
    #4
  5. dougloj

    TiSch Guest

    Re: Static Variables and Craziness

    On 6 Jan., 00:09, "dougloj" <> wrote:
    > I mainly save user account info, product info and order info in objects
    > of my own class types. These objects are static.


    You could save user informations in Session-Variables
    Syntax: Session("AccountInfo")=myAccountInfoObject

    regards,
    Tim
     
    TiSch, Jan 5, 2007
    #5
  6. dougloj

    dougloj Guest

    Re: Static Variables and Craziness

    TiSch wrote:
    > On 6 Jan., 00:09, "dougloj" <> wrote:
    > > I mainly save user account info, product info and order info in objects
    > > of my own class types. These objects are static.

    >
    > You could save user informations in Session-Variables
    > Syntax: Session("AccountInfo")=myAccountInfoObject
    >
    > regards,
    > Tim
     
    dougloj, Jan 6, 2007
    #6
    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. Jeff Trotman

    Re: Session Object Craziness

    Jeff Trotman, Jul 17, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    461
    Jeff Trotman
    Jul 18, 2003
  2. Martin c

    Namespace Craziness

    Martin c, Feb 10, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    593
    Steven Cheng[MSFT]
    Feb 13, 2004
  3. Mike Kamzyuk

    managed and native craziness

    Mike Kamzyuk, Apr 26, 2005, in forum: C++
    Replies:
    2
    Views:
    344
    Mike Kamzyuk
    Apr 26, 2005
  4. Sideswipe

    Delegation and generics craziness

    Sideswipe, Aug 11, 2008, in forum: Java
    Replies:
    9
    Views:
    408
    Daniel Pitts
    Oct 4, 2008
  5. Unknown Poster

    Copy Constructor Craziness

    Unknown Poster, Feb 4, 2004, in forum: Perl Misc
    Replies:
    6
    Views:
    167
    Jay Tilton
    Feb 9, 2004
Loading...

Share This Page