Solved

Redirect on first visit only - classic asp

Posted on 2009-05-14
5
680 Views
Last Modified: 2012-05-07
I know a fair deal about ASP.net but I'm not so great with classic ASP.

On a classic ASP site I need to forward the user on the **first** visit of the session to another page that displays some information. This information page is written in ASP.net and once the user has seen this information they may then carry on with browsing the classic ASP site as usual.

I'm not sure how to force the direct in classic ASP just one time only.

If I put a response.redirect in the classic ASP home page to the ASP.net page, every time that page is viewed the user will be redirected. However I just want this redirection to happen once at the start of the session.

Can anyone help?
0
Comment
Question by:g-spot
  • 4
5 Comments
 
LVL 3

Expert Comment

by:Xenus99
ID: 24384116
You can do it with cookies, If the cookie shows that is the first time visit do the response.redirect, otherwise the user can continue browsing the site.
0
 
LVL 11

Expert Comment

by:Sven
ID: 24384483
For the first visit/call per session you can use the following:
<%

If Session("FirstCall") = "" Then

  Response.Redirect "firstcall.asp"

  Session("FirstCall") = "false"

End If

%>

Open in new window

0
 
LVL 11

Expert Comment

by:Sven
ID: 24384508
If you want to track the user and only redirect him on his very first visit to your site, you have to set a cookie and read this cookie:
<%

If Request.Cookie("FirstVisit") = "" Then

  Response.Redirect "firstcall.asp"

  Response.Cookie("FistVisit") = "false"

End If

%>

Open in new window

0
 
LVL 11

Accepted Solution

by:
Sven earned 500 total points
ID: 24384558
Ahh! You need to set session and cookie before redirect. My mistake.

Use these code snippets:
<%

If Session("FirstCall") = "" Then

  Session("FirstCall") = "false"

  Response.Redirect "firstcall.asp"

End If

%>
 

<%

If Request.Cookie("FirstVisit") = "" Then

  Response.Cookie("FistVisit") = "false"

  Response.Redirect "firstcall.asp"

End If

%

Open in new window

0
 
LVL 11

Expert Comment

by:Sven
ID: 24449498
Remember that deactivating (session-)cookies will lead to a redirect on ever call! so you better give a hint to the user that he maybe have to allow cookies.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

912 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now