Solved

First Visit code

Posted on 2009-05-09
4
304 Views
Last Modified: 2013-11-26
In my code behind you see attached I have a random image loaded.

What I WANT to do is to load a movie the FIRST time they visit and then after 10 seconds load the Random code below.

If they revisit the page during same session, they won't see the movie.
Dim rand As New Random()
        Me.imgLogin.ImageUrl = String.Format("images/random/{0}.jpg", rand.Next(1, 5))
        Session("visit") = "true"

Open in new window

0
Comment
Question by:lrbrister
  • 2
4 Comments
 
LVL 17

Expert Comment

by:OriNetworks
ID: 24344565
I would use a session variable and edit the global.asa file to detect when the user visits the site using the Session_OnStart event.
http://www.w3schools.com/asp/ev_sess_onend_onstart.asp

So when someone visits the site for the first time, the session_onstart event runs and sets Session("FirstVisit")="true"

Then on that page that you run the video, you can use and if statement to see if firstvisit is still true and if so run the video and set Session("FirstVisit")=false else dont do anything because that means the video was already run.
0
 
LVL 20

Expert Comment

by:informaniac
ID: 24344939
You could probably use a cookie and store the user id in the cookie.

So the next time the user logins, you could check whether the cookie exists or not. If it exists then don't load the movie.
0
 
LVL 9

Expert Comment

by:tillgeffken
ID: 24345003

        Public Function IsNewVisit() As Bool
                If (HttpContext.Current.Session("Visited") Is Nothing) Then
                    HttpContext.Current.Session("Visited") = 1
                    Return True
                End If
        End Function

Open in new window

0
 
LVL 9

Accepted Solution

by:
tillgeffken earned 500 total points
ID: 24345017
Forgot a little something in my code there.


If (IsNewVisit()) Then
  'Show Movie
Else
  'Show Random Image
End If
   

        Public Function IsNewVisit() As Bool
                If (HttpContext.Current.Session("Visited") Is Nothing) Then
                    HttpContext.Current.Session("Visited") = 1
                    Return True
                End If
                Return False
        End Function

Open in new window

0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

785 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