Session_OnStart does not start

P

Prabhat

Hi All,

The "Session_OnStart" event doesnot fire if the website has .htm file as the
startup document. If I change the extension of the default document from
..htm to .asp then I can see the event fires, But now I cant change the
default page to .asp.

How can I make the Session_OnStart fire in that situation? Please suggest.

Thanks
Prabhat
 
E

Evertjan.

Prabhat wrote on 27 sep 2005 in microsoft.public.inetserver.asp.general:
The "Session_OnStart" event doesnot fire if the website has .htm file
as the startup document. If I change the extension of the default
document from .htm to .asp then I can see the event fires, But now I
cant change the default page to .asp.

How can I make the Session_OnStart fire in that situation? Please
suggest.

I suppose you define .htm as an asp-page in iis.
 
P

Patrice

As the page is static, why would you need to start a session for this htm
page ? It will start anyway the first time you hit a dynamic page...

The whole scenario could help but you could likely mess with the file
extension, have the htm file redirected to default.asp, using a "link" to a
dnyamic page from your htm page to trigger the start etc... For now I don't
see why you really need to open the session before you hit any dynamic
content...
 
P

Prabhat

Patrice said:
As the page is static, why would you need to start a session for this htm
page ? It will start anyway the first time you hit a dynamic page...

The whole scenario could help but you could likely mess with the file
extension, have the htm file redirected to default.asp, using a "link" to a
dnyamic page from your htm page to trigger the start etc... For now I don't
see why you really need to open the session before you hit any dynamic
content...

Hi Patrice,

Actually my home page is htm and I want to set some Session variable
whenever any body open the home page (like referral url) so that I can use
that in my application. I know that If i change the extension of the home
page to asp it will work, but that is not possible now. So can u suggest any
alternae so that my session will start.

I think i need to call some asp page from the html page but by staying in
the same html page. Please suggest.

Thanks
Prabhat
 
M

McKirahan

Prabhat said:
to

Hi Patrice,

Actually my home page is htm and I want to set some Session variable
whenever any body open the home page (like referral url) so that I can use
that in my application. I know that If i change the extension of the home
page to asp it will work, but that is not possible now. So can u suggest any
alternae so that my session will start.

I think i need to call some asp page from the html page but by staying in
the same html page. Please suggest.

Thanks
Prabhat

You could include an image tag on your home page to invoke an
ASP page that sets the session variable. For example,

<img src="SetSesVar.asp" border="0" width="0" height="0" alt="">
 
P

Prabhat

Brian Staff said:
IIS; default Web Site; Right-click; Properties; Home Diretcory TAB;
Configuration Button; App Mappings TAB...add extension .HTM to invoke asp.dll

Brian

Hi Brian,

That is great. If I set the .htm to invoke asp.dll it is working for me.

But I have few doubts. Can u please help me in that?

1) This will work for any htm file invoked in that webserver will invoke
asp.dll. Can I set the samilar setting for any perticulatr website?
2) What all i can provide in the "Limit to" field?
3) I think that may lead to performance of the web server and also I am not
sure if the web hosting company will set that value for that default website
or not. And my main purpose is to capture the Referral URL. So is there any
other method you know?

Thanks
Prabhat
 
P

Prabhat

You could include an image tag on your home page to invoke an
ASP page that sets the session variable. For example,

<img src="SetSesVar.asp" border="0" width="0" height="0" alt="">
Hi, that will work fine and the session will start. Also I think i can use
like: <script language="javascript" src="StartSession.asp"></Script>. But
this will not give the exact referral page URL. This will give the url as
the homepage.htm.

Thanks
Prabhat
 
M

McKirahan

Prabhat said:
Hi, that will work fine and the session will start. Also I think i can use
like: <script language="javascript" src="StartSession.asp"></Script>. But
this will not give the exact referral page URL. This will give the url as
the homepage.htm.

Thanks
Prabhat

"I think i need to call some asp page from the html page"
was asked and answered.

You never mentioned the "referral page" before.

You'll have to provide more details as to what you want to do.
 
P

Prabhat

"I think i need to call some asp page from the html page"
was asked and answered.

You never mentioned the "referral page" before.

You'll have to provide more details as to what you want to do.
Hi,

Yes getting the referral page from the website that has htm as the startup
document was my requirement.Your ans was correct as per my question, but I
could not get the session started when the htm file or wesite is opened from
the home page. Can you suggest any thing?

thanks
prabhat
 
P

Patrice

As the html page is static I can't see how you'll be able to trigger the
code that will grab this info... It needs to be triggered by this exact
request as you are interested in a variable that is dependent upon the
current request.

The cleanest solution would be to change this page to an ASP page (I know
you said you can't).

Other solutions would be tricky and complex (for example you could try to
see if VBScript code in an HTM page once the HTM extension is handled by the
ASP dll (IMO it uses just the extension) or if i'ts possible to add another
extension for ASP pages. You could also handle the request to the htm page
and handles this behind the scene (dont'know exactly but likely needs to
write a complex DLL to do that). Also you should be able also to get this
info from the IIS log if this is just for statistics...

As a side note the referal is optional. Your application should be able to
run without this info.

Good luck.
 
E

Evertjan.

Patrice wrote on 28 sep 2005 in microsoft.public.inetserver.asp.general:
As the html page is static I can't see how you'll be able to trigger
the code that will grab this info... It needs to be triggered by this
exact request as you are interested in a variable that is dependent
upon the current request.

The cleanest solution would be to change this page to an ASP page
(I know you said you can't).

Other solutions would be tricky and complex

I wouldn't say tricky:

add to your start.htm page:

<img src='/dummyjpg.asp' style='display:none;'>

and make a '/dummyjpg.asp' page containing only:

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

<%
response.end
%>
You don't need to send a .jpg, etc here!

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

The above will trigger the "Session_OnStart" event

However you don't need the "Session_OnStart" event,
as you can try this for '/dummyjpg.asp' page:

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

<%
if session("isNewSession") = "" then
session("isNewSession") = "noMore"
session("theNewsetVariable") = "Blah"
end if
response.end
%>
You don't need to send a .jpg, etc here!

=============
 
P

Prabhat

Patrice said:
As the html page is static I can't see how you'll be able to trigger the
code that will grab this info... It needs to be triggered by this exact
request as you are interested in a variable that is dependent upon the
current request.

The cleanest solution would be to change this page to an ASP page (I know
you said you can't).

Other solutions would be tricky and complex (for example you could try to
see if VBScript code in an HTM page once the HTM extension is handled by the
ASP dll (IMO it uses just the extension) or if i'ts possible to add another
extension for ASP pages. You could also handle the request to the htm page
and handles this behind the scene (dont'know exactly but likely needs to
write a complex DLL to do that). Also you should be able also to get this
info from the IIS log if this is just for statistics...

As a side note the referal is optional. Your application should be able to
run without this info.

Good luck.

Hi,

Yes my website witll run without the referal url. and also I cant change the
home page to .asp.

But as per your suggestion (also suggested by Evertjan and Brian) I can set
the IIS (asp.dll) to invoke on htm request. But that will be a performance
problem (I think). And as the website is hosted with the ISP so he w'nt set
the asp.dll to execute on htm request.

I think Evertjan has a good point in his reply to this post.

Thanks
Prabhat
 
P

Prabhat

Evertjan. said:
I wouldn't say tricky:

add to your start.htm page:

<img src='/dummyjpg.asp' style='display:none;'>

and make a '/dummyjpg.asp' page containing only:

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

<%
response.end
%>
You don't need to send a .jpg, etc here!

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

The above will trigger the "Session_OnStart" event

However you don't need the "Session_OnStart" event,
as you can try this for '/dummyjpg.asp' page:

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

<%
if session("isNewSession") = "" then
session("isNewSession") = "noMore"
session("theNewsetVariable") = "Blah"
end if
response.end
%>
You don't need to send a .jpg, etc here!

=============
Hi Evertjan, Thanks for this code.

I think I can do that in many ways, But still not able to get the best
solution yet for my requirement. Like:

1) I can do that If i set the asp.dll to invoke on htm request. So here the
session will start and my referral url will be set correctly. But it is
difficult to set the setting with ISP.

2) I can do as per you code here and can also do like:

Add a line of code in home page.htm
<script language="javascript" src="StartSession.asp"></Script>

in StartSession.asp I will not have only one line : <%@ Language=VBScript %>
so this will trigger the session_onstart. But if I try to get the referral
url in session_onstart then i will not get correct url. Because my asp file
was called by the home page so that will be my referral not the actual.

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?

I think I am comming to the end but not with a best solution.

Thanks
Prabhat
 
P

Patrice

The problem is that it will trigger another HTTP request. As he wants to
capture the refferer, it has to be the same HTTP request...
 
P

Patrice

You htm page could perhaps then alter the src attribute if the img tag
passing the referrer value on the querystring.
In the target ASP page you can then read the querystring to get the referrer
for the HTM page...
 
P

Prabhat

Patrice said:
The problem is that it will trigger another HTTP request. As he wants to
capture the refferer, it has to be the same HTTP request...
Yes, you are right. It must be same request.

Thanks
Prabhat
 
P

Prabhat

Patrice said:
You htm page could perhaps then alter the src attribute if the img tag
passing the referrer value on the querystring.
In the target ASP page you can then read the querystring to get the referrer
for the HTM page...

I was also thinking to get the referrer url using javascript and pass the
referer to asp file and set the Session varibale with the value. But my
problem is: I have set the Session("ReferralURL") variable in
Seesion_OnStart. And now I have write like:

if Session("ReferralURL") = "" then Session("ReferralURL") =
Request.QueryString(.......

But I have Session("ReferralURL") already there in session_ONStart so it
will set to homepage when ever I call the asp page from my homepage using
the src tag. What do you think?

I think you all are getting bore of this small issue. I am sorry for that
but I am not able to get the proper solution yet.

Thanks
Prabhat
 
P

Patrice

Why do you need to do this in session_start ? Why can't you do that inside
the ASP page ? I would try without anything in Session_Start and would fill
the session variable with the querystring value in the ASP page itself...

Later you'll likely have to consider changing the HTM page to an ASP page
for a cleaner approach (don't know why you can't change. In case it's
because you don't have access to the server config, note that you could have
multiple documents i.e. it will use default.htm if available but could be
able to use default.asp if default.htm is deleted).
 
P

Prabhat

Patrice said:
Why do you need to do this in session_start ? Why can't you do that inside
the ASP page ? I would try without anything in Session_Start and would fill
the session variable with the querystring value in the ASP page itself...

Because my seesion start from many places of the website. All pages except
the home page are asp. SO Instead of doing that in asp page i preferred to
do in session_onStart. But my problem was i was not able to capture referral
url when the user enter using home page. If the session starts only in home
page then you are right and i should also set that in ASP page instead if
session_OnStart.
Later you'll likely have to consider changing the HTM page to an ASP page
for a cleaner approach (don't know why you can't change. In case it's
because you don't have access to the server config, note that you could have
multiple documents i.e. it will use default.htm if available but could be
able to use default.asp if default.htm is deleted).

I think having a htm / html as start page provide a greater index to search
engines then a asp as home page. I am not sure but I think i will not be
able to change thet htm to asp.

Thanks
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,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top