473,397 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Static Variables and Craziness

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.

Jan 5 '07 #1
5 1676
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

Jan 5 '07 #2
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
Jan 5 '07 #3
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
Jan 5 '07 #4


On 6 Jan., 00:09, "dougloj" <doug...@msn.comwrote:
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

Jan 5 '07 #5

TiSch wrote:
On 6 Jan., 00:09, "dougloj" <doug...@msn.comwrote:
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
Jan 6 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: James | last post by:
Hello Java NG, I not sure if this is the right NG for this type of question but if not please let me know which is, TIA Any way first off let me say I'm a student and this WAS last weeks lab,...
9
by: Bryan Parkoff | last post by:
I have noticed that C programmers put static keyword beside global variable and global functions in C source codes. I believe that it is not necessary and it is not the practice in C++. Static...
8
by: Simone Chiaretta | last post by:
I've a very strange behaveour related to a website we built: from times to times, something should happen on the server, and all static variables inside the web application, both defined inside aspx...
1
by: Chris Nurse via .NET 247 | last post by:
Option Compare Text Module Module1 Sub Main() #If MyString = "ABC" Then MsgBox("You have been compiled!") #End If
28
by: Dennis | last post by:
I have a function which is called from a loop many times. In that function, I use three variables as counters and for other purposes. I can either use DIM for declaring the variables or Static. ...
5
by: Jesper Schmidt | last post by:
When does CLR performs initialization of static variables in a class library? (1) when the class library is loaded (2) when a static variable is first referenced (3) when... It seems that...
9
by: CDMAPoster | last post by:
About a year ago there was a thread about the use of global variables in A97: http://groups.google.com/group/comp.databases.ms-access/browse_frm/thread/fedc837a5aeb6157 Best Practices by Kang...
55
by: Zytan | last post by:
I see that static is more restricted in C# than in C++. It appears usable only on classes and methods, and data members, but cannot be created within a method itself. Surely this is possible in...
16
by: RB | last post by:
Hi clever people :-) I've noticed a lot of people stating not to use static variables with ASP.NET, and, as I understand it, the reason is because the variable is shared across user sessions -...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.