Redirecting (Response.Redirect)

You can redirect the browser to another URL with the Redirect method of the Response object.

If you are going to redirect the user anytime after the <HTML> tag then you need to turn on buffering. On some servers it may be on by default. The statement below turns on buffering.

<% Response.Buffer = True %>

Then you can redirect the browser by doing this.

<% Response.Redirect "whatever_the_page_is_called.asp" %>

So a typical page would look like the following, notice that as the redirect appears in the <body> HTML tag we need to have buffering turn on.

<%@ LANGUAGE="VBSCRIPT" %>
<% Option Explicit %>
<% response.buffer=true %>

<html>
<head>
<title>redirect page</title>
</head>

<body>
<%
response.redirect("http://www.codefixer.com")
%>

</body>
</html>

You can place different redirects within (if/else) statements or you can also use variables as in the example below.

Example:

<%@ LANGUAGE="VBSCRIPT" %>
<% Option Explicit %>
<% response.buffer=true %>

<html>
<head>
<title>redirect page</title>
</head>

<body>
<%
'declare your variable
Dim Page
Page = "mainpage.asp"
Response.Redirect (Page)
%>

</body>
</html>

LinksPro - Directory  and Link  Management Software

3 MONTHS FREE – ASP.NET Hosting w/ US and UK Data Centers – Click Here!

About | Contact | Advertise | Feedback | Hire Us | Link

Site developed by Michael Wall - Web Design Belfast N.Ireland.
Copyright © 2001-2009. All rights reserved.

ASP/.NET Hosting

asp.netPRO’s “Best ASP.NET Hosting” – Click Here!

MembersPro

MembersPro PayPal - ASP Membership software

Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.