I've got an extremely basic Global.asax file which records visitor information on each Session_Start event. The file uses an insert statement to add a record to a database each time a new session is started. My code for the insert statement is below.
strInsert = "Insert Into TBL_SESSION_LOG ( SessionID, StartTime, EndTime, ElapsedTime, PageCount, State, Referer, InitialRemoteHost, InitialRemoteAddress, UserAgent )"
strInsert = strInsert & " Values ( '" & Session.SessionID & "', #" & Now() & "#, #" & Now() & "#, 0, 0, True, '" & Request.ServerVariables("http_referrer") & "', '" & Request( "REMOTE_HOST" ) & "', '" & Request( "REMOTE_ADDR" ) & "', 'fred' )"
The values it returns all seem okay except for the final two.
Referer ---> Request.ServerVariable("http_referrer")
UserAgent ---> 'fred'
(The second one is a pretty obvious error!)
Although this code does not generate any errors when run, it does not seem to be recording any values for Referer. HOW CAN I MODIFY MY CODE TO ENSURE 'REFERRER' AND 'USERAGENT' VALUES ARE RECORDED? I believe I read somewhere that these values are generated per page returned from the site- not sure if Global.asax is a special exception which needs handling differently.