Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"aborting" in the middle of an asp page (or redirecting) 2

Status
Not open for further replies.

ChampionX

Technical User
May 24, 2001
5
ES
Hi,

I have a basic question, I am learning asp since a few days ago, so maybe it will be a dumb question... let's go:

I have a form.asp page which consists on a form which gather the data, then triggers update.asp which receives the form values and performs the update on the database.

I would like to prevent update.asp from being called without passing first through the form.asp (let's suppose the user tries to go straight there typing the url of update.asp). It's easy to check that the form values are empty, but once I know it, how do I say "Error" and stop? I've tried with server.abandon() but it doesn't seem to stop the "flow" of commands after it. They keep executing and of course they produce an ugly error which I don't want the user to see (although he deserves it for trying strange things :)

At last I have used something like this:

if value="" then response.redirect "form.asp"

, so that if there's no value, he gets redirected to the form where he should have came from. But then I have to set the response.buffer to true at the beginning of the document.

My question then is:

1) What is the .abandon() method useful for? Doesn't it stop the processing?
2) Is there any more elegant method than response.redirect + buffer=true for achieving the same result? Or is it already okay? I don't know if using buffer=true might have some negative effects I might be overlooking.

Thanks in advance for any help.

ChX.
 
response.buffer = true
+
response.redirect

is fine if that's what you want to use --

The way to stop the execution of a page is:
response.end

Dunno much about the server.abandon() method. In fact, I didn't know there was one. ;-)

There is a session.abandon method, and that will destroy any session variables and/or objects that happen to be attached to your user's session, and is the method that is called if you offer a 'logout' button for your site, and were/are using session variables.

:)
Paul Prewett
 
Thanks a lot link9. After reading your answer I realized that it was response.end() the method I was trying to use, but for some unknown reason, I was using server.abandon(). I mean, somehow the utility of response.end() and the name of "server.abandon()" got mixed up in my head :D

Thanks again!
 
Well...I'll try to explain it

.Abandon() - finish the client session's (nothing about asp renedering)

.end() - finish rendering the asp, even if you have more code after it (good for debugging)

.clear() - clear the asp buffer (I think that's what you want), ex:

...
response.write "you are the winner"...
if user <> &quot;winner&quot; then
response.clear
response.write &quot;looser&quot;
end if

good luck







 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top