471,850 Members | 1,106 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,850 software developers and data experts.

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 6602
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
NeoPa
reply views Thread by NeoPa | last post: by
reply views Thread by YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.