473,385 Members | 1,912 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.

What's better: using Application or Session object?? (in my case)

Hi,

I wanted to get some advices from you guys.
I have a little web-shop in ASP.NET for a project. I have several VB
classes, where the most important ones are the "DBmanager" and the
"DataManager". The DBManager creates the database connection and has
some useful functions. The DataManager has an Object of the DBManager
and uses that functions to get the Data as DataView, DataReader,....

Now to avoid that every time a user accesses the page, there is always
created a new Object of the DataManager and therefore also of the
DBManager which means also a new connection to the database, I wanted
to store the objects in the Session or Application object.

It is clear to me, that storing in the Session variable would meen that
it is specific for each user, meaning again that so for each
user-session those objects would be created. On the other hand, the
Application object would sound better to me, since in that case only at
each Application - start the objects would be created.

Can you give me advices. They can also be of completely different
nature.

thanks
Juri

Sep 16 '06 #1
2 1397
Hi,

kito wrote:
Hi,

I wanted to get some advices from you guys.
I have a little web-shop in ASP.NET for a project. I have several VB
classes, where the most important ones are the "DBmanager" and the
"DataManager". The DBManager creates the database connection and has
some useful functions. The DataManager has an Object of the DBManager
and uses that functions to get the Data as DataView, DataReader,....

Now to avoid that every time a user accesses the page, there is always
created a new Object of the DataManager and therefore also of the
DBManager which means also a new connection to the database, I wanted
to store the objects in the Session or Application object.

It is clear to me, that storing in the Session variable would meen that
it is specific for each user, meaning again that so for each
user-session those objects would be created. On the other hand, the
Application object would sound better to me, since in that case only at
each Application - start the objects would be created.

Can you give me advices. They can also be of completely different
nature.

thanks
Juri
Storing data in the Application has one additional disadvantage (other
than that it is not user-specific (actually, session-specific): It
requests careful management of stored data. The Application is recycled
only seldomly. If you forget to delete data stored in it, there is a
risk to create memory leaks. On the other hand, Sessions usually time
out after 20 minutes (that is, 20 minutes after the last access to
dynamic content). This minimizes the risk.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Sep 16 '06 #2
I know, therefore I do the following on startup, where the
Application_start event is fired:
Dim dbManager as new DBManager
Dim dataManager as new DataManager(dbManager)
Application("DBManager") = dbManager
Application("DataManager") = dataManager

In the method of the Application_end event, i do then the following:
Application("DBManager") = Nothing
Application("DataManager") = Nothing

May it also be better to lock the Application before writing?? Maybe
safer...
Anyway...what do you suggest me to use? In your opinion.

I think putting it into the Session variable could be also a Memory
issue. What if 100 or say more, load the webpage. Then 100 objects
would be created and with all of them also a DBConnection or not? I
mean in my case this will not happen, since it is only a project for
the University, but it will be marked for such things.

Thanks again

Juri

Laurent Bugnion wrote:
Hi,

Storing data in the Application has one additional disadvantage (other
than that it is not user-specific (actually, session-specific): It
requests careful management of stored data. The Application is recycled
only seldomly. If you forget to delete data stored in it, there is a
risk to create memory leaks. On the other hand, Sessions usually time
out after 20 minutes (that is, 20 minutes after the last access to
dynamic content). This minimizes the risk.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Sep 16 '06 #3

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

Similar topics

9
by: RA | last post by:
Hi Please review and let me know if I am correct: 1) My understanding from reading http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag/html/ diforwc-ch05.asp is that...
7
by: Nikhil Patel | last post by:
Hi all, I am using a Session object in my ASP.Net application to store a value of a Database field. I can access it as ... int iProposalId = Session; The session timeout is set to 20. Now my...
4
by: Jeremy Lew | last post by:
When my HttpHandler is processing a request when installed on a particular 2003 Server machine, the Context.Session object is null. Any idea why this might be? My handler implements...
2
by: John Mullin | last post by:
We are having a problem which appears similar to a previous posting: http://groups.google.com/groups?hl=en&lr=&frame=right&th=d97f552e10f8c94c&seekm=OZw33z9EDHA.2312%40TK2MSFTNGP10.phx.gbl#link1 ...
4
by: semsem22 | last post by:
hello, i m new to ASP.NET, but have experience with VB6....i have a couple of questions about the use of a module and the decleration of public objects in the module vs the use of sessions the...
13
by: | last post by:
Simple question, I think... I'm storing an object in the Session object. In the code behind I read that object: trx = CType(Session("Transaction"), BOCSTransaction) If I change any...
7
by: Rob | last post by:
Hi, I'm getting an error on my login page when using Javascript session object. It works on the development server so I'm wondering if there is a setting in IIS to allow using sessions on the...
1
by: Doogie | last post by:
I'm looking for some good reading material on the pros/cons of using the Session object and was wondering if anyone could point me in the right direction?
5
by: jamie.jamazon | last post by:
I'm currently developing a small MVC framework using classic ASP (don't ask me why!) At it's core it calls the controller script which does the heavy logic and builds disconnected recordsets of the...
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...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.