473,385 Members | 2,044 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,385 software developers and data experts.

vb .net variables in asp .net

Hi,

I have a simple question about vb .net variables. There is so much
info on variables out there I had trouble finding exactly what I am
looking for. Here is the question:

When I use a variable (for example Dim strWhatever As String) in
server code, is a new instance of the variable create for each user
who visits the page? I know I need session variables for user specific
information across multiple pages (there are other ways but session is
easiest). But if I'm using variables do something like figure the
interest on a loan payment, and the code is server side (not client
side), will there be a conflict if multiple people use my page
simultaneously or is it all separate? I know this is a rookie question
but I want to confirm the answer. Thanks. If you know of any good
links please send.
Nov 18 '05 #1
11 1320
It is all separate.

You have to use Session, Application, or Cache to share a variables between
users.

Greg

"Matt Mercer" <ma******@bellsouth.net> wrote in message
news:37**************************@posting.google.c om...
Hi,

I have a simple question about vb .net variables. There is so much
info on variables out there I had trouble finding exactly what I am
looking for. Here is the question:

When I use a variable (for example Dim strWhatever As String) in
server code, is a new instance of the variable create for each user
who visits the page? I know I need session variables for user specific
information across multiple pages (there are other ways but session is
easiest). But if I'm using variables do something like figure the
interest on a loan payment, and the code is server side (not client
side), will there be a conflict if multiple people use my page
simultaneously or is it all separate? I know this is a rookie question
but I want to confirm the answer. Thanks. If you know of any good
links please send.

Nov 18 '05 #2
Uh, well maybe not Session. :^)

"Greg Burns" <greg_burns@DONT_SPAM_ME_hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
It is all separate.

You have to use Session, Application, or Cache to share a variables
between users.

Greg

"Matt Mercer" <ma******@bellsouth.net> wrote in message
news:37**************************@posting.google.c om...
Hi,

I have a simple question about vb .net variables. There is so much
info on variables out there I had trouble finding exactly what I am
looking for. Here is the question:

When I use a variable (for example Dim strWhatever As String) in
server code, is a new instance of the variable create for each user
who visits the page? I know I need session variables for user specific
information across multiple pages (there are other ways but session is
easiest). But if I'm using variables do something like figure the
interest on a loan payment, and the code is server side (not client
side), will there be a conflict if multiple people use my page
simultaneously or is it all separate? I know this is a rookie question
but I want to confirm the answer. Thanks. If you know of any good
links please send.


Nov 18 '05 #3
ma******@bellsouth.net (Matt Mercer) wrote in
news:37**************************@posting.google.c om:
But if I'm using variables do something like figure the
interest on a loan payment, and the code is server side (not client
side), will there be a conflict if multiple people use my page
simultaneously or is it all separate?


It depends how you declare the variables. If you declare the variable as
static, it will be shared by all the users. If you declare it any other
way, it will be specific for each user.

You can share variables by using static, application, or cache variables.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #4
P.S. My understanding is that if you declare a variable static/shared, it's
shared only across that *instance* of the application, and I'm not sure you
can know when/whether IIS decides to fire up a new instance of the app. Can
anybody confirm?

Bill

"Lucas Tam" wrote:
ma******@bellsouth.net (Matt Mercer) wrote in
news:37**************************@posting.google.c om:
But if I'm using variables do something like figure the
interest on a loan payment, and the code is server side (not client
side), will there be a conflict if multiple people use my page
simultaneously or is it all separate?


It depends how you declare the variables. If you declare the variable as
static, it will be shared by all the users. If you declare it any other
way, it will be specific for each user.

You can share variables by using static, application, or cache variables.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 18 '05 #5
TJS
it's all separate, each request to the page gets reprocessed for each user.
Their inputs are processed and the variables only represent their
information. So, using something like Dim strWhatever As String is fine.


"Matt Mercer" <ma******@bellsouth.net> wrote in message
news:37**************************@posting.google.c om...
Hi,

I have a simple question about vb .net variables. There is so much
info on variables out there I had trouble finding exactly what I am
looking for. Here is the question:

When I use a variable (for example Dim strWhatever As String) in
server code, is a new instance of the variable create for each user
who visits the page? I know I need session variables for user specific
information across multiple pages (there are other ways but session is
easiest). But if I'm using variables do something like figure the
interest on a loan payment, and the code is server side (not client
side), will there be a conflict if multiple people use my page
simultaneously or is it all separate? I know this is a rookie question
but I want to confirm the answer. Thanks. If you know of any good
links please send.

Nov 18 '05 #6
You have to be careful here, "static" means something different in VB.NET
than it does in C#.

If you declare something as "static" in VB.NET, then the variable will
remain in scope even after its' local procedure ends. In VB.NET, if you
declare it as "shared", it is one value that is shared across all instances
of the class within one running application.
"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn**************************@140.99.99.130...
ma******@bellsouth.net (Matt Mercer) wrote in
news:37**************************@posting.google.c om:
But if I'm using variables do something like figure the
interest on a loan payment, and the code is server side (not client
side), will there be a conflict if multiple people use my page
simultaneously or is it all separate?


It depends how you declare the variables. If you declare the variable as
static, it will be shared by all the users. If you declare it any other
way, it will be specific for each user.

You can share variables by using static, application, or cache variables.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 18 '05 #7
You won't have conflicts, but you will be creating a new variable for each
user.
"Matt Mercer" <ma******@bellsouth.net> wrote in message
news:37**************************@posting.google.c om...
Hi,

I have a simple question about vb .net variables. There is so much
info on variables out there I had trouble finding exactly what I am
looking for. Here is the question:

When I use a variable (for example Dim strWhatever As String) in
server code, is a new instance of the variable create for each user
who visits the page? I know I need session variables for user specific
information across multiple pages (there are other ways but session is
easiest). But if I'm using variables do something like figure the
interest on a loan payment, and the code is server side (not client
side), will there be a conflict if multiple people use my page
simultaneously or is it all separate? I know this is a rookie question
but I want to confirm the answer. Thanks. If you know of any good
links please send.

Nov 18 '05 #8
A static/shared variable is shared within what's known as an app
domain. If IIS spins up a new instance of an ASP.NET application, it
will live in a new app domain.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Tue, 12 Oct 2004 20:05:07 -0700, Bill Borg
<Bi******@discussions.microsoft.com> wrote:
P.S. My understanding is that if you declare a variable static/shared, it's
shared only across that *instance* of the application, and I'm not sure you
can know when/whether IIS decides to fire up a new instance of the app. Can
anybody confirm?

Bill

"Lucas Tam" wrote:
ma******@bellsouth.net (Matt Mercer) wrote in
news:37**************************@posting.google.c om:
> But if I'm using variables do something like figure the
> interest on a loan payment, and the code is server side (not client
> side), will there be a conflict if multiple people use my page
> simultaneously or is it all separate?


It depends how you declare the variables. If you declare the variable as
static, it will be shared by all the users. If you declare it any other
way, it will be specific for each user.

You can share variables by using static, application, or cache variables.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/


Nov 18 '05 #9
Scott, something I've been trying to get an answer to for some time: Can IIS
spin up multiple instances of my application *at the same time*. Or, does it
always end the one before it starts the other? Does it change if I'm working
in a web garden?

Bill

"Scott Allen" wrote:
A static/shared variable is shared within what's known as an app
domain. If IIS spins up a new instance of an ASP.NET application, it
will live in a new app domain.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Tue, 12 Oct 2004 20:05:07 -0700, Bill Borg
<Bi******@discussions.microsoft.com> wrote:
P.S. My understanding is that if you declare a variable static/shared, it's
shared only across that *instance* of the application, and I'm not sure you
can know when/whether IIS decides to fire up a new instance of the app. Can
anybody confirm?

Bill

"Lucas Tam" wrote:
ma******@bellsouth.net (Matt Mercer) wrote in
news:37**************************@posting.google.c om:

> But if I'm using variables do something like figure the
> interest on a loan payment, and the code is server side (not client
> side), will there be a conflict if multiple people use my page
> simultaneously or is it all separate?

It depends how you declare the variables. If you declare the variable as
static, it will be shared by all the users. If you declare it any other
way, it will be specific for each user.

You can share variables by using static, application, or cache variables.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/


Nov 18 '05 #10
Hi Bill:

Here is my understanding of the scenario - I think I can find some
official documentation on this if need be.

When a new instance of the application spins up it begins taking
requests before the old instance exists. All new requests are sent to
the new instance of the application while the old instance is allowed
to finish processing any requests it already has in the pipeline
(effectively a drain stop operation, in clustering terms).

I don't think there is any way to have more than one instance of an
ASP.NET application taking on new requests at the same time - except
with web gardening in IIS 6. Then you can have one worker process per
CPU - each taking incoming requests.

Even in a web garden though these are seperate appdomains. Each
instance will have it's own application state and static members.

Actually, I take back what I said in the third paragraph. There
probably are ways to have more than one active instance without
webGardens, but you'd have to write something with ISAPI, so it's
probably not worth the effort, know what I mean?

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 20 Oct 2004 10:07:04 -0700, Bill Borg
<Bi******@discussions.microsoft.com> wrote:
Scott, something I've been trying to get an answer to for some time: Can IIS
spin up multiple instances of my application *at the same time*. Or, does it
always end the one before it starts the other? Does it change if I'm working
in a web garden?

Bill


Nov 18 '05 #11
Scott, this helps, thanks for the additional effort.

"Scott Allen" wrote:
Hi Bill:

Here is my understanding of the scenario - I think I can find some
official documentation on this if need be.

When a new instance of the application spins up it begins taking
requests before the old instance exists. All new requests are sent to
the new instance of the application while the old instance is allowed
to finish processing any requests it already has in the pipeline
(effectively a drain stop operation, in clustering terms).

I don't think there is any way to have more than one instance of an
ASP.NET application taking on new requests at the same time - except
with web gardening in IIS 6. Then you can have one worker process per
CPU - each taking incoming requests.

Even in a web garden though these are seperate appdomains. Each
instance will have it's own application state and static members.

Actually, I take back what I said in the third paragraph. There
probably are ways to have more than one active instance without
webGardens, but you'd have to write something with ISAPI, so it's
probably not worth the effort, know what I mean?

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Wed, 20 Oct 2004 10:07:04 -0700, Bill Borg
<Bi******@discussions.microsoft.com> wrote:
Scott, something I've been trying to get an answer to for some time: Can IIS
spin up multiple instances of my application *at the same time*. Or, does it
always end the one before it starts the other? Does it change if I'm working
in a web garden?

Bill


Nov 18 '05 #12

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

Similar topics

5
by: Ross A. Finlayson | last post by:
Hi, I'm scratching together an Access database. The development box is Office 95, the deployment box Office 2003. So anyways I am griping about forms and global variables. Say for example...
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...
7
by: misha | last post by:
Hello. I was wandering if someone could explain to me (or point to some manual) the process of mapping the addresses of host variables by DB2. Especially I would like to know when DB2 decides to...
5
by: Sandman | last post by:
I dont think I understand them. I've read the section on scope in the manual inside out. I'm running PHP 5.2.0 Here is the code I'm working on: //include_me.php <?php $MYVAR = array(); global...
1
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.