Closing a conneciton in the “unload” method
问题 I have inherited a web framework whereby the previous developer has opened and closed his database connections in the init/unload methods of the page life cycle. Essentially constructor is like this (simplified to demonstrate the point); public class BasePage { protected DBConnection _conn; public BasePage() { Init += StartConnection; Unload += EndConnection; } private void StartConnection(object sender, EventArgs e) { _conn = new DBConnection(Application["connectionstring"].ToString()); }