Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Static Variables and Craziness

Reply
Thread Tools

Static Variables and Craziness

 
 
dougloj
Guest
Posts: n/a
 
      01-05-2007
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.

 
Reply With Quote
 
 
 
 
TiSch
Guest
Posts: n/a
 
      01-05-2007
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

 
Reply With Quote
 
 
 
 
Hans Kesting
Guest
Posts: n/a
 
      01-05-2007
> 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


 
Reply With Quote
 
dougloj
Guest
Posts: n/a
 
      01-05-2007
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


 
Reply With Quote
 
TiSch
Guest
Posts: n/a
 
      01-05-2007


On 6 Jan., 00:09, "dougloj" <(E-Mail Removed)> 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

 
Reply With Quote
 
dougloj
Guest
Posts: n/a
 
      01-06-2007

TiSch wrote:
> On 6 Jan., 00:09, "dougloj" <(E-Mail Removed)> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delegation and generics craziness Sideswipe Java 9 10-04-2008 02:29 AM
managed and native craziness Mike Kamzyuk C++ 2 04-26-2005 08:42 PM
Namespace Craziness Martin c ASP .Net 3 02-13-2004 12:38 AM
"Special edition" craziness Grand Inquisitor DVD Video 13 11-21-2003 02:52 AM
Re: Session Object Craziness Jeff Trotman ASP .Net 2 07-18-2003 06:00 AM



Advertisments