468,747 Members | 1,790 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,747 developers. It's quick & easy.

Response.End() in server-side JavaScript try-catch-finally...

Hi.

Just one question: if I call Response.End() in an ASP server-side JavaScript
catch() block *and* I have a finally{} block, will the latter be skipped or will
it still be executed?

The reason is I place instructions to close an ADO connection in finally blocks
whenever I need to close a DB connection. I also have instructions that I
execute in a catch() block whenever an error occurs. These instructions clear
the Response buffer, output the error message and End() the Response stream. But
I want to make sure my connection is actually closed.

Vince C.
Jul 19 '05 #1
2 6534
Vince C. wrote:
Hi.

Just one question: if I call Response.End() in an ASP server-side
JavaScript catch() block *and* I have a finally{} block, will the
latter be skipped or will it still be executed?
No. All page activity ceases when Response.End is executed.

This is easy enough to test. Put code in your finally() block that creates a
text file or writes data to a database. The raise an error that will trigger
your catch() block and see if the action in your finally() block occurred.

The reason is I place instructions to close an ADO connection in
finally blocks whenever I need to close a DB connection. I also have
instructions that I execute in a catch() block whenever an error
occurs. These instructions clear the Response buffer, output the
error message and End() the Response stream. But I want to make sure
my connection is actually closed.

Don't use Response.End until after you close the connection

Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #2
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> a écrit dans le message de
news:ew**************@tk2msftngp13.phx.gbl...
[...]
Don't use Response.End until after you close the connection


Thanks a lot, Bob. Bug fixed. As I also presume this is true with
Response.Redirect(), I've made sure my connection is closed *before*
redirecting.

Vince C.
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Paul de Goede | last post: by
1 post views Thread by Alex Nitulescu | last post: by
1 post views Thread by emielvl | last post: by
5 posts views Thread by =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?= | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.