Wednesday, October 20, 2021

ASP Primer: Sending a Response, part 2

ASP Primer:

Sending a Response

by Curtis Dicken

 

Use these bookmarks
to jump around the tutorial:

[Response.Write:
Talking to the User

[Response.Redirect:
Moving the User Around
]

[Response.Cookies:
Memorizing Stuff About the User
]

[What’s
Next?
]

 

Response.Redirect:
Moving the User Around

 

Response.Redirect
is kind of like a call forwarding button. It sends the user on to any location
you designate.

 

The syntax is virtually
the same as Response.Write. Instead of entering a word or phrase that you
want to be sent to the browser, you enter the URL of the destination that you
want the user to be redirected to. For example:

 

<% Response.Redirect

      
"http://www.HTMLGoodies.com" %>

 

The code above will send
the user on to the HTMLGoodies web site. You can also assign
Response.Redirect
a destination from a variable like this:

 

<% Option Explicit %>

<% Dim strDestination %>

 

<% strDestination =
"http://www.HTMLGoodies.com" %>

 

<% Response.Redirect
strDestination %>

 

So, why would I ever use
this?

 

The most common usage
for Response.Redirect is in processing user input. Let’s say, for
example, you have built an ASP application that allows you and your friends to
exchange DVD’s and keep track of them. One of your pages is a form that asks the
user whether they want to add a DVD to the list, delete a DVD from the list,
borrow a DVD or return a DVD. Once they have made a selection you can then send
them off to the appropriate page by using Response.Redirect in
cooperation with a Case statement.

 

There are, of course,
other valuable uses for Response.Redirect, but the type of situation
listed above is the most common.

<< Previous | Next >>

Popular Articles

Featured