473,387 Members | 1,530 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,387 software developers and data experts.

Issue with public variables

I have an ASP.NET application, which needs to initialize a memory
location and update it multiple times in different projects in the same
solution. I have used a public static variable and I could achive what
I want. The problem is when User1 opens the application and starts
updating the variable, and User2 opens the application from a
different machine and tries to modify the value in the public variable,
User1's value is being affected. How do I overcome this?
Thanks in advance!

Jun 29 '06 #1
8 1128
If each user has a different value for this variable, then clearly using a
static variable is not the way to go. Static variables should only be used
for system wide settings. Not for user specific settings.

You need to store user specific settings in session or via another user
specific mechanism.

<rk****@gmail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
I have an ASP.NET application, which needs to initialize a memory
location and update it multiple times in different projects in the same
solution. I have used a public static variable and I could achive what
I want. The problem is when User1 opens the application and starts
updating the variable, and User2 opens the application from a
different machine and tries to modify the value in the public variable,
User1's value is being affected. How do I overcome this?
Thanks in advance!

Jun 29 '06 #2
Thanks for the response, Marina. I mentioned it as a variable but it's
actually an object, which I cannot put in a Session variable. Can you
give examples of "user specific mechanism" you mentioned.
Thanks

Marina Levit [MVP] wrote:
If each user has a different value for this variable, then clearly using a
static variable is not the way to go. Static variables should only be used
for system wide settings. Not for user specific settings.

You need to store user specific settings in session or via another user
specific mechanism.

<rk****@gmail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
I have an ASP.NET application, which needs to initialize a memory
location and update it multiple times in different projects in the same
solution. I have used a public static variable and I could achive what
I want. The problem is when User1 opens the application and starts
updating the variable, and User2 opens the application from a
different machine and tries to modify the value in the public variable,
User1's value is being affected. How do I overcome this?
Thanks in advance!


Jun 29 '06 #3
I have an object at my blog. to handle storing objects. (I'm not sure if
this is what you're asking about or not)

You could easily copy and modify it to have a Session Store, or an
Application Store.
http://sholliday.spaces.msn.com/
10/24/2005 Entry
Web Session Wrapper for storing and retrieving objects

<rk****@gmail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
I have an ASP.NET application, which needs to initialize a memory
location and update it multiple times in different projects in the same
solution. I have used a public static variable and I could achive what
I want. The problem is when User1 opens the application and starts
updating the variable, and User2 opens the application from a
different machine and tries to modify the value in the public variable,
User1's value is being affected. How do I overcome this?
Thanks in advance!

Jun 29 '06 #4
You can put objects in Session if it is in memory session, or serializable.

I think other user specific mechanism would be storing it in the Application
object by session, or rolling your own session - which all really amounts to
the same thing when you want to store user specific values on the server.

<rk****@gmail.com> wrote in message
news:11**********************@y41g2000cwy.googlegr oups.com...
Thanks for the response, Marina. I mentioned it as a variable but it's
actually an object, which I cannot put in a Session variable. Can you
give examples of "user specific mechanism" you mentioned.
Thanks

Marina Levit [MVP] wrote:
If each user has a different value for this variable, then clearly using
a
static variable is not the way to go. Static variables should only be
used
for system wide settings. Not for user specific settings.

You need to store user specific settings in session or via another user
specific mechanism.

<rk****@gmail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
>I have an ASP.NET application, which needs to initialize a memory
> location and update it multiple times in different projects in the same
> solution. I have used a public static variable and I could achive what
> I want. The problem is when User1 opens the application and starts
> updating the variable, and User2 opens the application from a
> different machine and tries to modify the value in the public variable,
> User1's value is being affected. How do I overcome this?
> Thanks in advance!
>

Jun 29 '06 #5
any particular reason you can't store this in the session ?
it sounds like you are saying that objects in general can't be stored in the
session which is just plain wrong.
<rk****@gmail.com> wrote in message
news:11**********************@y41g2000cwy.googlegr oups.com...
Thanks for the response, Marina. I mentioned it as a variable but it's
actually an object, which I cannot put in a Session variable. Can you
give examples of "user specific mechanism" you mentioned.
Thanks

Marina Levit [MVP] wrote:
If each user has a different value for this variable, then clearly using a static variable is not the way to go. Static variables should only be used for system wide settings. Not for user specific settings.

You need to store user specific settings in session or via another user
specific mechanism.

<rk****@gmail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
I have an ASP.NET application, which needs to initialize a memory
location and update it multiple times in different projects in the same solution. I have used a public static variable and I could achive what
I want. The problem is when User1 opens the application and starts
updating the variable, and User2 opens the application from a
different machine and tries to modify the value in the public variable, User1's value is being affected. How do I overcome this?
Thanks in advance!

Jun 29 '06 #6
Thank you! hope you answer another small question. In my solution, I
have a Web project and a Class library project. How do I access Session
variables in Class library project, which are set in Web project?
Thanks in advance!

sloan wrote:
I have an object at my blog. to handle storing objects. (I'm not sure if
this is what you're asking about or not)

You could easily copy and modify it to have a Session Store, or an
Application Store.
http://sholliday.spaces.msn.com/
10/24/2005 Entry
Web Session Wrapper for storing and retrieving objects

<rk****@gmail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
I have an ASP.NET application, which needs to initialize a memory
location and update it multiple times in different projects in the same
solution. I have used a public static variable and I could achive what
I want. The problem is when User1 opens the application and starts
updating the variable, and User2 opens the application from a
different machine and tries to modify the value in the public variable,
User1's value is being affected. How do I overcome this?
Thanks in advance!


Jun 29 '06 #7
System.Web.HttpContext.Current.Session

<rk****@gmail.com> wrote in message
news:11**********************@b68g2000cwa.googlegr oups.com...
Thank you! hope you answer another small question. In my solution, I
have a Web project and a Class library project. How do I access Session
variables in Class library project, which are set in Web project?
Thanks in advance!

sloan wrote:
I have an object at my blog. to handle storing objects. (I'm not sure if
this is what you're asking about or not)

You could easily copy and modify it to have a Session Store, or an
Application Store.
http://sholliday.spaces.msn.com/
10/24/2005 Entry
Web Session Wrapper for storing and retrieving objects

<rk****@gmail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
> I have an ASP.NET application, which needs to initialize a memory
> location and update it multiple times in different projects in the same
> solution. I have used a public static variable and I could achive what
> I want. The problem is when User1 opens the application and starts
> updating the variable, and User2 opens the application from a
> different machine and tries to modify the value in the public variable,
> User1's value is being affected. How do I overcome this?
> Thanks in advance!
>

Jun 29 '06 #8
Thank you All!

Marina Levit [MVP] wrote:
System.Web.HttpContext.Current.Session

<rk****@gmail.com> wrote in message
news:11**********************@b68g2000cwa.googlegr oups.com...
Thank you! hope you answer another small question. In my solution, I
have a Web project and a Class library project. How do I access Session
variables in Class library project, which are set in Web project?
Thanks in advance!

sloan wrote:
I have an object at my blog. to handle storing objects. (I'm not sure if
this is what you're asking about or not)

You could easily copy and modify it to have a Session Store, or an
Application Store.
http://sholliday.spaces.msn.com/
10/24/2005 Entry
Web Session Wrapper for storing and retrieving objects

<rk****@gmail.com> wrote in message
news:11**********************@d56g2000cwd.googlegr oups.com...
> I have an ASP.NET application, which needs to initialize a memory
> location and update it multiple times in different projects in the same
> solution. I have used a public static variable and I could achive what
> I want. The problem is when User1 opens the application and starts
> updating the variable, and User2 opens the application from a
> different machine and tries to modify the value in the public variable,
> User1's value is being affected. How do I overcome this?
> Thanks in advance!
>


Jun 29 '06 #9

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

Similar topics

11
by: VK | last post by:
Folks, An aspx page has some querystring variables in the URL. In the code beind file, I tried requesting these variables and setting as public variables, so it is not specific to a sub. ...
12
by: Ken | last post by:
I am familiar with C and Java, I would like to use a style that I have become accustomed to in Java with C++ but each time I do this I have name conflict. In the past I have just worked around it...
1
by: Ray Ackley | last post by:
I'm experiencing a threading problem that's really perplexing me. I have a multithreaded application that reads car ECU information that's sent over the serial port by the ECU and received by the...
4
by: Nick Dreyer | last post by:
Is it possible to see public class variables of a COM addin in Excel 97 VBA? I have successfully created the (Visual Basic 2003 .NET) COM and referenced it in an Excel 97 VBA project. The VBA...
9
by: Kelii | last post by:
I've been trying to get this piece to work for a few hours, but have given up. I hope someone out there can help, I think the issue is relatively straightforward, but being a novice, I'm stumped....
7
by: Victor | last post by:
I just tried a test comparing a Function to a Private Function with this code: <% Option Explicit dim X1 X1 = 9 Private Function RealTest(here) RealTest = here + X1 End Function
4
by: fniles | last post by:
I create a thread where I pass thru a message. When I click very fast many times (like 50 times) to create 50 threads, the message did not get pass thru ProcessMessage. For example: strBuffer =...
7
by: darrel | last post by:
This is a long-overdue item on my punch list that I haven't had much time to address in the past. I'm trying to get it off my plate this week. ;o) We have a home-grown CMS that works pretty well....
1
by: Tom Baxter | last post by:
Hi All, I was hoping someone could clarify something I read in the C# Language Spec regarding "Definite Assignment" of structs. This is a very subtle point. I am referring to ECMA-334, section...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.