Application[] storage issue

  • Thread starter Thread starter Curt tabor
  • Start date Start date
C

Curt tabor

Hello,

I am creating a dbConnection for use through out my application and
storing it in an Application variable. I am doing this in the
Application_Start event in the Global.asax file. The first time the app
is run and a page needs this variable, Application["connection"]
returns null. Subsequent calls to the application work fine. This only
happens on the first run. Is there a better way? Is this some sort of
bug?

Thanks

Curt
 
I'd have to see the code to know exactly what is wrong, but I'd
suggest not taking this approach. You don't want to share a connection
among multiple requests - it will eventually break in mysterious ways.

Open a new connection when you need one and close it as soon as you
are done. The runtime will take care of keeping things running
efficiently.
 

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

Back
Top