Connection in ASP.NET

Thread is closed for posting
3 posts, 1 answers
  1. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 14 Jul 2011 Link to this post


    maybe a double post, but regarding Open Access I'm always asking myself if I'm reading a post or a blog on the old or the new way... the doc and blogs are not dated so that makes it that much harder...

    I'm having some general questions regarding Open Access, latest version Q2 2011. I'll post them separately.

    Q: In the car rental demo a per request context connection is demonstrated. if, at any time in the lifcycle of the request a connection is requested, a instance of the context is created and saved in the request. in the Application.EndRequest event the context is closed.

    Isn't this slowing down every request? why not save it at httpapplication level? (HttpContext.Current.Application("var")=new context)

    Can I also consider an per session connection? what do you advise in a multiuser environment?


  2. Answer
    Zoran avatar
    534 posts

    Posted 15 Jul 2011 Link to this post

    Hello Erik,

     The creation of a context is a very lightweight operation and is not slowing the application down. Creating/Disposing a context does not mean opening and closing a connection. The connections are held in a pool which is on its side static for the application. When a context decides to perform a CRUD operation it just gets a connection from the pool and that connection is already initialized so you have minimal performance penalty for that operation. If the context is only created and disposed - it doesn't even get a connection from the pool so there is absolutely no performance penalty with that approach.

    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. Erik
    Erik avatar
    314 posts
    Member since:
    Feb 2008

    Posted 19 Jul 2011 Link to this post

    Hi Zoran,

    Ok, if you say so, I'll believe you... :-)

    when I'm debugging it seems to last a while, but well, thats debugging of course..

    I'm gone try it out, thanks.

Back to Top