4 ms·
>One thing they did get right: wrapping the connection object in a "using" block so it is guaranteed to be disposed of correctly. True, but the page redirect h
by artmageddon 15y ago
>One thing they did get right: wrapping the connection object in a "using" block so it is guaranteed to be disposed of correctly.
True, but the page redirect happens within the using block. I would assume that the disposal still happens, but this is very very bad form.
- funkah 15y agoGood point. I'm about 95% sure the disposal would still happen, but I agree it's bad form. This code is terrible in so many ways I didn't even consider that.
- JonoW 15y agoThat code is filled with all sorts of horrors (Sql injection, passwords in plain-text in DBs, passwords sent in query-string, all logic in web-layer), but redirecting in a using block is ok, the disposers will always be called (outside of fatal exceptions like StackOverflows)
- city41 15y agousing is syntactic sugar for a try/finally block with a Dispose call in the finally. So yes, the dispose will still happen.