Session_OnStart does not start

E

Evertjan.

Prabhat wrote on 28 sep 2005 in microsoft.public.inetserver.asp.general:
3) I can use Java Script on my Homepage like: document.referrer and I can
use the value in some asp file where I will set the referral url (Session
variable). But how do I pass that value to the asp page?


<body onload='
document.getElementById("im").src=
"/dummy.asp?ref=" + document.referrer
'>
<img id='im' style='display:none;'>

not tested
 
P

Prabhat

Evertjan. said:
<body onload='
document.getElementById("im").src=
"/dummy.asp?ref=" + document.referrer
'>
<img id='im' style='display:none;'>

not tested

yes that should do that trick.

Thanks
Prabhat
 
P

Patrice

Ok and what do you have in your session variable ? IMO you'll have to test
that the session variable is not already set but also you'll have to test
that the referrer is not on your own site before taking it into account.

This way :
- if you hit the HTM page : the ASP "trick" page is called, it makes the
session start but the referrer (from ServerVariables) is not taken as it's
on your own site, the page runs and take the referrer into account (coming
from the QueryString)
- if you hit directly an ASP page, the session start and the referrer (from
ServerVariables) is taken into account as it's not on your site

As I said earlier, make sure you can play without this info as the browser
could not provide necessarily this info...
 
P

Prabhat

Patrice said:
Ok and what do you have in your session variable ? IMO you'll have to test
that the session variable is not already set but also you'll have to test
that the referrer is not on your own site before taking it into account.

This way :
- if you hit the HTM page : the ASP "trick" page is called, it makes the
session start but the referrer (from ServerVariables) is not taken as it's
on your own site, the page runs and take the referrer into account (coming
from the QueryString)
- if you hit directly an ASP page, the session start and the referrer (from
ServerVariables) is taken into account as it's not on your site

Hi Patrice, you are right. I should check what is in the url before I assign
that referrer url to the session veriable. So both the way it will work fine
and I will be done in that.
As I said earlier, make sure you can play without this info as the browser
could not provide necessarily this info...

But I did not get the above line. Any how thanks.
Prabhat
 
P

Prabhat

Brian Staff said:
You might have a problem with your host (invoking asp.dll for an HTM request),
but performance will be non-existant. You will not be able to measure the
difference.

Brian

Hi Brian, thanks for that info about performance. But yes you are right the
ISP will not agree to set to invoke the asp.dll for HTML pages :( But I
think as I discussed with Patrice and Evertjan that should do the trick.

Thanks
Prabhat
 
P

Prabhat

Evertjan. said:
<body onload='
document.getElementById("im").src=
"/dummy.asp?ref=" + document.referrer
'>
<img id='im' style='display:none;'>

not tested

Hi Evertjan,

I have created one sample asp file Start.asp:

Start.asp
-----------
<%@ Language=VBScript %>
<%
dim sRef
sRef = Request.QueryString("ref")

Wfile="D:\test.txt"

Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.CreateTextFile(Wfile,True)
a.WriteLine("URL : " & sRef)
a.Close

set a = nothing
set fs = nothing
%>


and called like :

<BODY onload='document.getElementById("im").src="/start.asp?ref=" +
document.referrer'>
<img id='im' style='display:none;'>

But I think it is not calling the ASP file as the test.txt does not get
created.

So I called like:

<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY>
<script language = javascript TYPE="TEXT/JAVASCRIPT" src='Start.asp?ref=' +
document.referrer ></script>

<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
if (document.referrer != '')
document.write('Thanks for visiting from ' + document.referrer)
else
document.write('NONE')
</SCRIPT>
</BODY>
</HTML>

It is creating the test.txt but no Referral URL. can you suggest?

Thanks
Prabhat
 
E

Evertjan.

Prabhat wrote on 29 sep 2005 in microsoft.public.inetserver.asp.general:
<BODY onload='document.getElementById("im").src="/start.asp?ref=" +
document.referrer'>
<img id='im' style='display:none;'>

But I think it is not calling the ASP file as the test.txt does not
get created.

I have two solutions for you, both tested overhere on a distant ASP-site:

CLIENTSIDE REFERRER SOLUTION:

Try this for your test.html file:

==================
<BODY onload='document.getElementById("im").src="/dummyjpg.asp?ref=" +
document.referrer + "&random=" + Math.random()'>

<img src='' id='im' style='display:none;'>

<a href='show.asp'>show</a>
==================

the Math.random ensures the dummyjpg.asp is fetched every time
src='' is probably necessary.

Try this for your dummyjpg.asp file:

==================
<% Response.Expires = 0 %>
<%
if session("ref") = "" then
session("ref") = Request.QueryString("ref")
end if
%>
==================

And this for your show.asp file:

==================
<% Response.Expires = 0 %>
<%
response.write session("ref")
%>
==================

Mind:

If the test.html is callet from localhost, perhaps there is no referrer
string, so call this file from alother file on a server with:

<a href='http://www.myTestDomain.org/test1.html'>start the test</a>

=========================================================================

SERVERSIDE REFERRER SOLUTION:

Try this for your test.html file:

==================
<BODY onload='document.getElementById("im").src=
"/dummyjpg.asp?random=" + Math.random()'>
<img src='' id='im' style='display:none;'>

<a href='show.asp'>show</a>
==================

Try this for your dummyjpg.asp file:

==================
<% Response.Expires = 0 %>
<%
if session("ref") = "" then
session("ref") = Request.ServerVariables("HTTP_REFERER")
end if
%>
==================

And this for your show.asp file:

==================
<% Response.Expires = 0 %>
<%
response.write session("ref")
%>
==================
 
P

Prabhat

Evertjan. said:
Prabhat wrote on 29 sep 2005 in microsoft.public.inetserver.asp.general:

I have two solutions for you, both tested overhere on a distant ASP-site:

CLIENTSIDE REFERRER SOLUTION:

Try this for your test.html file:

==================
<BODY onload='document.getElementById("im").src="/dummyjpg.asp?ref=" +
document.referrer + "&random=" + Math.random()'>

<img src='' id='im' style='display:none;'>

<a href='show.asp'>show</a>
==================

the Math.random ensures the dummyjpg.asp is fetched every time
src='' is probably necessary.

Try this for your dummyjpg.asp file:

==================
<% Response.Expires = 0 %>
<%
if session("ref") = "" then
session("ref") = Request.QueryString("ref")
end if
%>
==================

And this for your show.asp file:

==================
<% Response.Expires = 0 %>
<%
response.write session("ref")
%>
==================

Mind:

If the test.html is callet from localhost, perhaps there is no referrer
string, so call this file from alother file on a server with:

<a href='http://www.myTestDomain.org/test1.html'>start the test</a>

=========================================================================

SERVERSIDE REFERRER SOLUTION:

Try this for your test.html file:

==================
<BODY onload='document.getElementById("im").src=
"/dummyjpg.asp?random=" + Math.random()'>
<img src='' id='im' style='display:none;'>

<a href='show.asp'>show</a>
==================

Try this for your dummyjpg.asp file:

==================
<% Response.Expires = 0 %>
<%
if session("ref") = "" then
session("ref") = Request.ServerVariables("HTTP_REFERER")
end if
%>
==================

And this for your show.asp file:

==================
<% Response.Expires = 0 %>
<%
response.write session("ref")
%>
==================

Hi Evertjan, I think I am makking you angry :( Sorry. And thanks for your
suggestions. I will try that now.

Thanks
Prabhat
 
E

Evertjan.

Prabhat wrote on 29 sep 2005 in microsoft.public.inetserver.asp.general:
Hi Evertjan, I think I am makking you angry :( Sorry. And thanks for your
suggestions. I will try that now.

No, you don't.

I am learning too!
 
P

Prabhat

No, you don't.

I am learning too!

Hi,

Thanks for that code samples. Actually the Client side code is what I was
looking for. I have just tested the files in remote site and it is working
fine. But not working in local site (i have not used localhost in local,
instead used computer name). Ok any how I will find the cause of that. Any
how that need to be implemented in remote not local.

Thanks Evertjan
Prabhat
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top