SEMI-Advanced ASP Code behavior question

Results 1 to 3 of 3

Thread: SEMI-Advanced ASP Code behavior question

  1. #1
    Jim Davies Guest

    Default SEMI-Advanced ASP Code behavior question

    As a C++/PERL/Delphi programmer, I am use to exiting a program, for example in my ASP code I would like to check that all form fields are entered correctly. Then if they are not I want to redirect the users to another page but assure that the code below the redirect does NOT run.<BR><BR>If not (checkFields) then<BR>Response.Redirect("")<BR>End if<BR><BR><BR>My question is in ASP, if I call redirect, as above, does the code below the redirect statement execute, I mean, will ASP just redirect and exit or will ASP Redirect and run the code in the background?<BR><BR><BR>The reason for the post is I think I am doing unnecessary things; I do it this way because I am ignorant to ASP behavior.<BR><BR>If not (checkFields) then<BR>Iserror=True<BR>Response.Redirect("")<BR>End if <BR><BR>If not isError then<BR><BR><BR>Generally, any help on the behavior of ASP, when does ASP exit, how can I force it to exit, how can I run code then exit a program then assure that some code is executed.<BR><BR>On anther note, how do I assure that code is run? In Delphi, I can exit a program use:<BR><BR>Try...<BR>&#060;Code here&#062;<BR>Exit if needed<BR>Finally<BR>&#060;Code after finally, will "always" be executed&#062;<BR>end<BR><BR>I find this most important because If I open a database (as well as other tasks), I want to be sure that the connection is closed no matter what I do in code, in many cases I need to assure that we clean up.<BR><BR> <BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: SEMI-Advanced ASP Code behavior question

    I believe asp will stop processing the page when a redirect is encountered. also &#060;% response.end %&#062; will stop execution

  3. #3
    Join Date
    Dec 1969

    Default Reality or theory?

    Response.Redirect and Response.End immediately stop the processing of the current page.<BR><BR>If you want to do DB cleanup, etc., you will have to code it yourself. There is no FINALLY or anything like it in VBScript. I would suggest a "cleanup" SUB or FUNCTION that you call both before doing a page end or transfer and before a normal page end.<BR><BR>I would note that, contrary to "urban legend", VBScript *should* successfully close all open database connections, etc., and recover all objects without help from you whenever a page ends, normally or abnormally. Early versions of ASP and VBS had several bugs in this regard, but if you look at how sloppily most ASP is coded today, you&#039ll see that if those bugs still existed then most IIS servers would be rebooted every 22 minutes.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts