The finally code will always get executed, so the first case is fine.
Interstingly enought your catch code will also get reached 100% of the time.
Response.Redirect throws a ThreadAbordException, so your code in the try{}
block will always throw an exception, which will be caught and rethrown by
your catch, and your finally will clean up. Since the thread is aborted,
everything works fine..so it's ok....but it is pretty interesting :)
On a side note, you probably don't want to rethrow the exception, consider
replace your catch code with:
Catch obj_Exception as Exception
Throw
which, instead of throwing an exception of type Exception with an
innerException of the actual type, will actually throw the original
exception with all the juicy information readily available. Check out:
http://dotnetguy.techieswithcats.com...s/004118.shtml for a better
explenation (if you are interested)
Karl
"Henry" <m3***********@hotmail.com> wrote in message
news:et**************@TK2MSFTNGP09.phx.gbl...
Hello,
I have a question about ASP.NET process. In this case:
Try
'SOME CODE
Response.Redirect("some_asp_page.aspx")
Catch obj_Exception as Exception
Throw obj_Exception
Finally
If Not (obj_Conn Is Nothing) Then obj_Conn.Dispose()
End Try
I wonder if ASP.NET reaches the finally part of the code or does it
redirect and neever reaches the finally statement?
Or should write something like this?
Try
'SOME CODE
Catch obj_Exception as Exception
Throw obj_Exception
Finally
If Not (obj_Conn Is Nothing) Then obj_Conn.Dispose()
Response.Redirect("some_asp_page.aspx")
End Try
Which one should I use?
Thanks in advance?
Henry