g Text Version
Beauty & Self
Books & Music
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
News & Politics
Religion & Spirituality
Travel & Culture
TV & Movies

Bored? Games!
Take a Quiz
Rate My Photo

Home Improvement
Women's Fashion
Small Office/Home Office
Holiday/Seasonal Cooking
Crafts for Kids

All times in EST

Full Schedule
g ASP Site

BellaOnline's ASP Editor


Using Response.Redirect to Change Pages

The response.redirect command in ASP helps you automatically redirect to a new page if you need to. It's great for showing Thank You pages or moving through form processing.

Let's say you have a contact form, that asks a user for their email address and the text of their message to you. You can see the basics of ASP form creation in the Making an ASP Form page.

So let's say you send this form along to the page FormProcess.asp to do the processing. In this page, you take in the email address and message, and mail it off to your webmaster account for review. So far so good. If you actually want to learn how to do this, I have an Article on Mailing with ASP on the site.

But now that the mail message is sent, you want to say thank you to your user! It took them time and effort to write that comment to you, even if it was a short comment. The best way to do this is, at the end of your FormProcess.asp script, to send that user automatically to a thank you page. You would do that with the Response.Redirect command.

The most important thing to understand with this command is that you CANNOT have put any HTML at all on the screen before you start redirecting elsewhere. So in our example here, the user got a page with a form. They filled out the page and hit SUBMIT. They were sent to FormProcess.asp which was a processing page. This had ASP code in it but it did NOT WRITE ANY HTML. It didn't put a HEAD or BODY or anything else on the page with a response.write command. It simply took in the email address and message and created a mail message with it.

Once that processing is done, you can then say


the script will then merrily launch the thankyou.asp page, which can show your thank you message and let them continue to explore your site.

Remember, the user physically LEAVES YOUR FIRST SCRIPT when they hit that redirect command. So don't have any other commands beneath it! They will not get executed. Make sure all of your connections are closed and other cleanup is done before you send the user to the new page.

If you get an error that resembles:

Response object error 'ASP 0156 : 80004005
Header Error
/index.asp, line 22
The HTTP headers are already written to the client browser. Any HTTP header modifications must be made before writing page content.

then read more about The HTTP Headers Error

Also, you might want to read How Buffering Works in ASP

Introduction to ASP Ebook

Download this ebook to get everything you need to know about learning ASP - from a step by step tutorial to function lists, sample code, common errors and solutions, and much more! 101 pages.
Add Using+Response%2ERedirect+to+Change+Pages to Twitter Add Using+Response%2ERedirect+to+Change+Pages to Facebook Add Using+Response%2ERedirect+to+Change+Pages to MySpace Add Using+Response%2ERedirect+to+Change+Pages to Del.icio.us Digg Using+Response%2ERedirect+to+Change+Pages Add Using+Response%2ERedirect+to+Change+Pages to Yahoo My Web Add Using+Response%2ERedirect+to+Change+Pages to Google Bookmarks Add Using+Response%2ERedirect+to+Change+Pages to Stumbleupon Add Using+Response%2ERedirect+to+Change+Pages to Reddit

RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map

For FREE email updates, subscribe to the ASP Newsletter

Past Issues

Printer Friendly
tell friend
Tell a Friend
Email Editor

Content copyright © 2015 by Lisa Shea. All rights reserved.
This content was written by Lisa Shea. If you wish to use this content in any manner, you need written permission. Contact Lisa Shea for details.


g features
Regular Expression Pattern Matching

Split ASP String Function

Saving Changes is Not Permitted error

Archives | Site Map


Past Issues

Less than Monthly

BellaOnline on Facebook

| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2015 Minerva WebWorks LLC. All rights reserved.

BellaOnline Editor