session variables and global.aspx.cs - where do i put them?

T

tony collier

if i put an array in

public class Global : System.Web.HttpApplication
{

//e.g.

public static int [] count=new int[5]

}

and then refer to it in my page .cs files as Global.count[0].... [4] will
every session in my application be accessing the same count array or will
they each have their own?

I guess i am really saying is, is there a difference between the above and
:

protected void Session_Start(Object sender, EventArgs e)
{

Sesson["count"]=new int[5]

}


It strikes me that if they are the same then the first option is better
because i don't have to keep casting from object to int everytime i access
the array in web pages.
 
G

Guest

Hi Tony,

You should think of the Application scope the same way you would think of Environment variables.
They are not only global, but they are also readable and writable to all users of the system at the same
time.

Session is better to use if the values are not final or need to be changed per user.
A session is created for each user making a request.

____________________________________
Wil Moore III, MCP | Integrations Specialist | Senior Consultant
Business | Personal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top