Codefixer - ASP tutorials, resources and software
ASP.NET 3.5/2.0 Hosting – Click Here
Home   Articles   Resources   ASP directory   ASP Tutorials   Code Snippets   ASP Applications   Forum
Saturday 10 May
MembersPro PayPal - ASP Membership software

DiscountASP.NET – ASP.NET 3.5/2.0 Hosting


ASP Partner ASP Partner ASP Partner more partners...

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




ASP.NET 3.5/2.0 Web Hosting: 3 Months FREE – Click Here!




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

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

Do you intend to move to ASP.NET or have you already?
Yes will do
Have done
ASP does fine
Not a priority


Directory Software