I have started developing a full-web application by using the ASP .NET MVC 3 framework. I am a MVC 3 beginner developer.
On the server-side I am going to execute some queries to a DB. Consequently I will have to make a connection to the DB.
I would like to know if it is better to make a connection in the beginning of each action method or in an event handler. I have thought about making the connection in the Application_Start event handler and then storing an object representing my connection into the application state. Does this way present disadvantages ?
Thanks in advance for your future answer
Open and close the connection as required (rather than keeping one open). Let connection pooling work for you.
10 Tips for Writing High-Performance Web Applications (ASP.NET but contains relevant advice):