Application object

N

Nikhil Patel

Hi all,
If I read the contents of a file in the Application_Start event and store
it in the Application object so that the contents is available to all
sessions, what is the best way to remove the contents from memory when all
sessions have ended? Is there any better alternative to do this?
Thanks.
Nikhil
 
S

Scott Allen

You could keep the file in the Cache object. The ASP.NET cache will
automatically remove items using a least recently used algorithm. You
can also hook up a CacheDependency to invalidate the cached file it it
changes during runtime.
 
J

Josh

There is a Remove option on the application object and Application_End event
I believe
 
H

Hans Kesting

Nikhil said:
Hi all,
If I read the contents of a file in the Application_Start event and
store it in the Application object so that the contents is available
to all sessions, what is the best way to remove the contents from
memory when all sessions have ended? Is there any better alternative
to do this? Thanks.
Nikhil

A sidenote: what if new sessions come along after the first batch
ended and the object was removed? They will get a null value from
you Application!
Then again, this might be exactly what you want.

Hans Kesting
 

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,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top