static vs appsession

R

rodchar

hey all,

if i wanted to instantiate my business class just once is there a difference
between making a static variable out of it and putting it in say application
session?

thanks,
rodchar
 
H

Hans Kesting

rodchar laid this down on his screen :
hey all,

if i wanted to instantiate my business class just once is there a difference
between making a static variable out of it and putting it in say application
session?

thanks,
rodchar

Yes, a very big difference:
A static variable would be shared by all users of your site.
A Session variable would be visible to a single session only (and other
sessions would have other instances of it)

Hans Kesting
 
G

Gregory A. Beamer

hey all,

if i wanted to instantiate my business class just once is there a
difference between making a static variable out of it and putting it
in say application session?

thanks,
rodchar

Session or Application?

The difference here is Session is per user, Application is for all
users.

A static class is essentially the same for both, unless you share a
single process for multiple apps, in which case it is possible to have
an object across multiple sites with a static class. Otherwise, they are
functionally the same.

The perf over static versus storing in application is similar. You might
end up with a small amount of overhead with a Application object, but
you can still use static methods, properties, etc when storing in
application.

If you mean the Session object, static will not work.

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
G

Gregory A. Beamer

rodchar laid this down on his screen :

Yes, a very big difference:
A static variable would be shared by all users of your site.
A Session variable would be visible to a single session only (and
other sessions would have other instances of it)

Hans Kesting

I think the OP means the Application object, not Session object.

peace and grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 

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

Similar Threads

static vs session 2
Static vs Application in Global.aspx.cs 3
dropdownlist selectedindexchanged 1
static and base classes 2
what's the difference 3
html table cast 3
string, int and session 5
session and sql 1

Top