I have asp.net mvc site, my action generate the page, using master page. on master page included widgets by RenderAction helper. How can i use one database connection in page controller and in widget controller?
+3
A:
Generally you shouldn't need to worry about this, because connection pooling will take care of it automatically. Just make sure to close your connections when you're done with them (best is to use the using {}
block in your code, which will automatically close and dispose your connection).
If you really need to work off the same connection object for some reason, why not have all your controllers inherit from a base controller that exposes your connection object as a property?
womp
2010-01-21 23:42:31
does connections pool good thing for perfomance?
hippout
2010-01-21 23:46:42
Yes. You can read up on it in many places - here's one link: http://aspalliance.com/1099_Understanding_Connection_Pooling_in_NET
womp
2010-01-21 23:50:19
One problem with the using{} block is managing transactions.
Andrew
2010-01-22 01:49:18
You shouldn't be managing transactions in your controller code. If you're doing something that requires transactions, it should be abstracted into a seperate data access layer.
U62
2010-01-22 13:43:32
Can you suggest any example ?
ANIL MANE
2010-03-07 16:33:59