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

Muliple Users aspx project

Hi-

I have created a .NET web application that uses 6 aspx pages. As the
users goes from one page to the next several variables are set and
displayed on future pages. I found out today that if one person is on
Step 4, for instance, if another user goes to Step 3, all of the
information the 1st user entered displays. Am I missing a setting in
Webconfig or in IIS that allows each user to get their own instance of
the program? Any help is needed as I am on a tight timeline. Thanks

Nov 19 '05 #1
11 1262
<gr******@comcast.net> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi-

I have created a .NET web application that uses 6 aspx pages. As the
users goes from one page to the next several variables are set and
displayed on future pages. I found out today that if one person is on
Step 4, for instance, if another user goes to Step 3, all of the
information the 1st user entered displays. Am I missing a setting in
Webconfig or in IIS that allows each user to get their own instance of
the program?


There is no "program" for users to get an instance of. Please go to MSDN and
read about the ASP.NET page lifecycle.

Your pages use global variables. NEVER use global variables. Use Session
state to give each user a separate copy of some data.

John Saunders
Nov 19 '05 #2
Seems like something's wrong with your code. Where are these values being
stored? The application variable?

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
<gr******@comcast.net> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi-

I have created a .NET web application that uses 6 aspx pages. As the
users goes from one page to the next several variables are set and
displayed on future pages. I found out today that if one person is on
Step 4, for instance, if another user goes to Step 3, all of the
information the 1st user entered displays. Am I missing a setting in
Webconfig or in IIS that allows each user to get their own instance of
the program? Any help is needed as I am on a tight timeline. Thanks

Nov 19 '05 #3
I am using Global variables stored in a module. The guy above says to
use session state. I am new to this and am not really sure what that
is. Can you help?

Nov 19 '05 #4
Griz:
Check out my article on this:
http://openmymind.net/DataStorage/index.html

It should be helpful. I'd like to see the global variable code...is it
something like:

public shared SomeVaraible as Something?

or Application.Add("SomeKey", Something) or what? you could provide SOME
code to get some more meaningful help...

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
<gr******@comcast.net> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
I am using Global variables stored in a module. The guy above says to
use session state. I am new to this and am not really sure what that
is. Can you help?

Nov 19 '05 #5
the code is something like this

public gsFirstName as string
public gsLastName as string

Then I capture the variables on the first page, and display it again on
the fourth page. I do this with several variables. When one user has
given the variables a value, another user somewhere else will display
that value when they go to the appropriate page. So, all users are
sharing the same variables, and I can't have that happen. I am used to
VB6 windows forms, and didn't realize this would happen with webforms.

Nov 19 '05 #6
<gr******@comcast.net> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...
the code is something like this

public gsFirstName as string
public gsLastName as string


This is exactly your problem. Please do yourself a big favor and read The
ASP.NET Page Object Model
(http://msdn.microsoft.com/library/de...sp?frame=true).
Web forms are very different from Windows Forms, and .NET is very different
from VB6.

Many of the things you are used to from VB6 are just plain wrong with Web
Forms, and even with VB.NET in general. In particular, I strongly recommend
that anyone coming from VB6 should replace every single Module with the
equivalent Class. Modules are totally foreign to .NET and I believe it was
a mistake on the part of Microsoft to support them as is (there should have
been a converter).

If your Module had been a class, it might have been more obvious to you that
there was never going to be more than one instance of gsFirstName across all
users, as you would have declared it as:

Public Shared gsFirstName As String
John Saunders
Nov 19 '05 #7
public gsFirstName as string
public gsLastName as string

IE: gsFirstName = TheFirstNameValue

These are available to evryone using the application, instead use Session
Variables, they are available to only the active users session.

Session("FirstName") = TheFirstNameValue
Session("LastName") = TheLastNameValue

B Comrie
http://www.codewidgets.com

<gr******@comcast.net> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi-

I have created a .NET web application that uses 6 aspx pages. As the
users goes from one page to the next several variables are set and
displayed on future pages. I found out today that if one person is on
Step 4, for instance, if another user goes to Step 3, all of the
information the 1st user entered displays. Am I missing a setting in
Webconfig or in IIS that allows each user to get their own instance of
the program? Any help is needed as I am on a tight timeline. Thanks

Nov 19 '05 #8
This is very helpful. I have one question though. Where do i declare
the session variables? Since I ran into this problem, I have been
reading many groups and researching the problem. Do I declare the
variables in global.asax or on each webform? Thanks in advance.
B. Comrie wrote:
public gsFirstName as string
public gsLastName as string

IE: gsFirstName = TheFirstNameValue

These are available to evryone using the application, instead use Session Variables, they are available to only the active users session.

Session("FirstName") = TheFirstNameValue
Session("LastName") = TheLastNameValue

B Comrie
http://www.codewidgets.com

<gr******@comcast.net> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi-

I have created a .NET web application that uses 6 aspx pages. As the users goes from one page to the next several variables are set and
displayed on future pages. I found out today that if one person is on Step 4, for instance, if another user goes to Step 3, all of the
information the 1st user entered displays. Am I missing a setting in Webconfig or in IIS that allows each user to get their own instance of the program? Any help is needed as I am on a tight timeline. Thanks


Nov 19 '05 #9
<gr******@comcast.net> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
This is very helpful. I have one question though. Where do i declare
the session variables? Since I ran into this problem, I have been
reading many groups and researching the problem. Do I declare the
variables in global.asax or on each webform? Thanks in advance.


You don't have to declare them at all. They're not "variables", really.

"Session" (aka Page.Session, or Page.Context.Session) is an instance of the
HttpSessionState class. You can treat it as a collection of name-value
pairs. You can set a value with syntax like

Session("FirstName") = TheFirstNameValue

and then you can retrieve it with

Dim o As Object = Session("FirstName")

Note that Session(string) returns an Object, so you'll have to cast it to
the correct type:

Dim s As String = DirectCast(Session("FirstName"), String)

Note the use of DirectCast, which is correct since you know that it's a
string (you put it there, after all). Do not use CType or ToString in these
cases, as though you didn't know what type of value you put there.

Note also that this is subject to spelling errors - Session("FirstNam") will
return Nothing. I usually solve this problem by wrapping session state in a
class and using properties of the class to access it:

Public Class UserState
....
Public Shared Property FirstName As String
Get
Return DirectCast(HttpContext.Current.Session("FirstName" ),
String)
End Get
Set(ByVal Value As String)
HttpContext.Current.Session("FirstName") = Value
End Set
End Property
...
End Class

This way, there are only two places for a typo to happen. I would access
this from a page as UserState.FirstName. This can be accessed from multiple
pages.

BTW, Note the use of HttpContext.Current.Session. Since class UserState
isn't a Page, it doesn't have a "Session" member, so the Shared HttpContext
member "Current" is used to access the current request context.
John Saunders
Nov 19 '05 #10
so, on webform1 I can "declare" the variable like this

session("FirstName") = txtfirstname.text

and then display it on , say, page 4 with

lblfirstname.text = session("FirstName")?

also, can you calculate with these variables like

session("Subtotal") = session("Integer1") * session("Integer2")?

Thanks again
John Saunders wrote:
<gr******@comcast.net> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
This is very helpful. I have one question though. Where do i declare the session variables? Since I ran into this problem, I have been
reading many groups and researching the problem. Do I declare the
variables in global.asax or on each webform? Thanks in advance.
You don't have to declare them at all. They're not "variables",

really.
"Session" (aka Page.Session, or Page.Context.Session) is an instance of the HttpSessionState class. You can treat it as a collection of name-value pairs. You can set a value with syntax like

Session("FirstName") = TheFirstNameValue

and then you can retrieve it with

Dim o As Object = Session("FirstName")

Note that Session(string) returns an Object, so you'll have to cast it to the correct type:

Dim s As String = DirectCast(Session("FirstName"), String)

Note the use of DirectCast, which is correct since you know that it's a string (you put it there, after all). Do not use CType or ToString in these cases, as though you didn't know what type of value you put there.

Note also that this is subject to spelling errors - Session("FirstNam") will return Nothing. I usually solve this problem by wrapping session state in a class and using properties of the class to access it:

Public Class UserState
...
Public Shared Property FirstName As String
Get
Return DirectCast(HttpContext.Current.Session("FirstName" ), String)
End Get
Set(ByVal Value As String)
HttpContext.Current.Session("FirstName") = Value
End Set
End Property
...
End Class

This way, there are only two places for a typo to happen. I would access this from a page as UserState.FirstName. This can be accessed from multiple pages.

BTW, Note the use of HttpContext.Current.Session. Since class UserState isn't a Page, it doesn't have a "Session" member, so the Shared HttpContext member "Current" is used to access the current request context.
John Saunders


Nov 19 '05 #11
<gr******@comcast.net> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
so, on webform1 I can "declare" the variable like this

session("FirstName") = txtfirstname.text

and then display it on , say, page 4 with

lblfirstname.text = session("FirstName")?

also, can you calculate with these variables like

session("Subtotal") = session("Integer1") * session("Integer2")?
No, because "*" is not a valid operator for the Object type.

You'll need

Session("Subtotal") = DirectCast(Session("Integer1"), Integer) *
DirectCast(Session("Integer2"), Integer)

You _are_ running with Options Strict On, aren't you?

John Saunders
Thanks again
John Saunders wrote:
<gr******@comcast.net> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
> This is very helpful. I have one question though. Where do i declare > the session variables? Since I ran into this problem, I have been
> reading many groups and researching the problem. Do I declare the
> variables in global.asax or on each webform? Thanks in advance.


You don't have to declare them at all. They're not "variables",

really.

"Session" (aka Page.Session, or Page.Context.Session) is an instance

of the
HttpSessionState class. You can treat it as a collection of

name-value
pairs. You can set a value with syntax like

Session("FirstName") = TheFirstNameValue

and then you can retrieve it with

Dim o As Object = Session("FirstName")

Note that Session(string) returns an Object, so you'll have to cast

it to
the correct type:

Dim s As String = DirectCast(Session("FirstName"), String)

Note the use of DirectCast, which is correct since you know that it's

a
string (you put it there, after all). Do not use CType or ToString in

these
cases, as though you didn't know what type of value you put there.

Note also that this is subject to spelling errors -

Session("FirstNam") will
return Nothing. I usually solve this problem by wrapping session

state in a
class and using properties of the class to access it:

Public Class UserState
...
Public Shared Property FirstName As String
Get
Return

DirectCast(HttpContext.Current.Session("FirstName" ),
String)
End Get
Set(ByVal Value As String)
HttpContext.Current.Session("FirstName") = Value
End Set
End Property
...
End Class

This way, there are only two places for a typo to happen. I would

access
this from a page as UserState.FirstName. This can be accessed from

multiple
pages.

BTW, Note the use of HttpContext.Current.Session. Since class

UserState
isn't a Page, it doesn't have a "Session" member, so the Shared

HttpContext
member "Current" is used to access the current request context.
John Saunders

Nov 19 '05 #12

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

Similar topics

6
by: mark | last post by:
I have an asp.net ecommerce web application on a remote web server. I'm using an Access database on the back end. I've notice a few strange things. When I mimic an multiple user environment by...
0
by: Ying | last post by:
All, I have a page that is pulling data from SQL Server onto 1 aspx page. The page requires two seperate datagrinds. One on top and one right below it. They are displaying different data, but...
4
by: Darrel | last post by:
I'm creating a table that contains multiple records pulled out of the database. I'm building the table myself and passing it to the page since the table needs to be fairly customized (ie, a...
2
by: pv | last post by:
Hi everyone, I need help with following scenario, please: Users are accessing same web server from intranet (users previously authenticated in Active Dir) and from extranet (common public...
1
by: ABC | last post by:
I have a new project which is a web site used by Internal and External users (login required users) and public users (no login required users). On internal users, all users login network using...
1
by: Arun | last post by:
I have a folder “Secured” under the root folder of the project In the project root web.config authentication is given as <authentication mode="Forms"> <forms loginUrl="Login.aspx" timeout="15"...
1
by: Arpan | last post by:
Suppose a web.config file (existing in C:\Inetpub\wwwroot\ASPX) has the following code: <configuration> <system.web> <authentication mode="Forms"> <forms name="AuthenticateUser"...
1
by: goose28 | last post by:
Instructions for creating a silent install project in Visual Studio.NET 2003 for "All Users". 1) Create a default setup project for your application using Visual Studio (File/New/Setup and...
2
by: Ceebaby via AccessMonster.com | last post by:
Hi Folks I wondered if someone could point me in the right direction before I completely tear my hair out. I have a user selection form where options can be selected for a report. Users now...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shllpp 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.