Application[] storage issue

Discussion in 'ASP .Net' started by Curt tabor, Nov 4, 2005.

  1. Curt tabor

    Curt tabor Guest

    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
    Curt tabor, Nov 4, 2005
    #1
    1. Advertising

  2. Curt tabor

    Scott Allen Guest

    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.

    --
    Scott
    http://www.OdeToCode.com/blogs/scott/

    On 4 Nov 2005 11:22:13 -0800, "Curt tabor" <> wrote:

    >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
    Scott Allen, Nov 4, 2005
    #2
    1. Advertising

  3. Curt tabor

    Curt tabor Guest

    OK. Thanks.

    Curt
    Curt tabor, Nov 4, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pradeep Kumar C

    Storage of Application Variable

    Pradeep Kumar C, Oct 30, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    457
    Kevin Spencer
    Nov 1, 2004
  2. sarathy
    Replies:
    2
    Views:
    660
    sarathy
    Jul 17, 2006
  3. bsm
    Replies:
    2
    Views:
    930
  4. Srini
    Replies:
    11
    Views:
    967
    Arne Vajhøj
    Jun 1, 2008
  5. mfaulcon

    AD/ADAM and application settings storage

    mfaulcon, Jul 27, 2006, in forum: ASP .Net Security
    Replies:
    2
    Views:
    130
    Dominick Baier
    Jul 27, 2006
Loading...

Share This Page