Global.asa

E

Evertjan.

Shahid Juma wrote on 28 sep 2004 in
microsoft.public.inetserver.asp.general:
I placed my global.asa file into a subfolder in the wwwroot folder. It
doesn't seem to work when I try to use the sessions that have been
declared there.

It is only read if it is in the root.

Placing it somwhere else is illogical,
as it is only read at the start of the asp application.
 
S

Shahid Juma

Hi,

I placed my global.asa file into a subfolder in the wwwroot folder. It
doesn't seem to work when I try to use the sessions that have been declared
there.

Any ideas?

Thanks,
Shahid
(remove the words "REMOVETHIS" when replying to email address)
 
R

Ray Costanzo [MVP]

In order for that global.asa to be executed, the directory in which it
resides needs to be defined as an application in IIS. If global.asa is in
an ordinary old directory in your site, it will just be an arbitrary file.

Ray at work
 
T

Tom Kaminski [MVP]

Shahid Juma said:
Hi,

I placed my global.asa file into a subfolder in the wwwroot folder. It
doesn't seem to work when I try to use the sessions that have been
declared
there.

Any ideas?

You need to set that folder as an application through the IIS mmc.

--
Tom Kaminski IIS MVP
http://www.microsoft.com/windowsserver2003/community/centers/iis/
http://mvp.support.microsoft.com/
http://www.iisfaq.com/
http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS
http://www.tryiis.com
 
T

Tom Kaminski [MVP]

Evertjan. said:
Shahid Juma wrote on 28 sep 2004 in
microsoft.public.inetserver.asp.general:


It is only read if it is in the root.

Placing it somwhere else is illogical,
as it is only read at the start of the asp application.

It does not need to be in the IIS server root, but rather the application
root - which can be set anywhere.

--
Tom Kaminski IIS MVP
http://www.microsoft.com/windowsserver2003/community/centers/iis/
http://mvp.support.microsoft.com/
http://www.iisfaq.com/
http://www.iistoolshed.com/ - tools, scripts, and utilities for running IIS
http://www.tryiis.com
 
S

Shahid Juma

Evertjan. said:
Shahid Juma wrote on 28 sep 2004 in
microsoft.public.inetserver.asp.general:


It is only read if it is in the root.

Placing it somwhere else is illogical,
as it is only read at the start of the asp application.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress,
but let us keep the discussions in the newsgroup)

I tried that too and it didn't work. Example, I placed this in the
global.asa file: When I try to use the GetUnixTime or use the
ConnectionString session variable, it responds back by saying that it
doesn't exist.

Shahid

<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Sub Application_OnStart
End Sub

Sub Application_OnEnd
End Sub

Sub Session_OnStart
Session("ConnectionString") = ""
Session("ConnectionTimeout") = 15
Session("CommandTimeout") = 30
End Sub

Sub Session_OnEnd
End Sub
</SCRIPT>

<script language="JScript" runat="server">
function GetUnixTime(strDate) {
if (strDate) {
return new Date(strDate).valueOf();
}
else {
return 0;
}
}
</script>
 
A

Aaron [SQL Server MVP]

You can't have a function like that in global.asa... that is what #includes
are for, not global.asa...
 
S

Shahid Juma

Aaron said:
You can't have a function like that in global.asa... that is what #includes
are for, not global.asa...

Regardless, even when I remove the function, it still doesn't work. Says
session doesn't exist.

Shahid
 
A

Aaron [SQL Server MVP]

Ugh, learn to trim.
Regardless, even when I remove the function, it still doesn't work. Says
session doesn't exist.

"WHAT" still doesn't work? "WHAT" says session doesn't exist?

A
 
M

Mark Schupp

Do you have session state enabled for the application directory (IIS
manager, virtual directory properties, virtual directory tab, configuration
button,app options tab)?

--
Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
 
S

Shahid Juma

Global.asa file
----------
<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Sub Application_OnStart
End Sub

Sub Application_OnEnd
End Sub

Sub Session_OnStart
Session("ConnectionString") = ""
Session("ConnectionTimeout") = 15
Session("CommandTimeout") = 30
End Sub

Sub Session_OnEnd
End Sub
</SCRIPT>

-----------------

in an asp file when I try to get the ConnectionString, so conn =
Session("ConnectionString"), it then complains that the object/session
doesn't exist.

Shahid
 
P

Patrice

Could you check :
- place gloal.asa at the root of the application
- make sure the directory where the file is it configured as an application
- make sure that for this application session are enable

Those two last are checked by using the IIS Service manager...

Hope it helps

Patrice
 
R

Ray Costanzo [MVP]

I think we're all still wondering what "it" is, especially since something
like Response.Write Session("something") won't "complain" if the something
variable doesn't exist. Also, have you read any of the other replies that
are telling you that your global.asa file has to be in the root of a defined
application in IIS? Additionally, is "enable session state" checked in your
application configuration in IIS?

Ray at work
 
S

Shahid Juma

Yes I have placed it in the root. When I try to use the connectionstring to
open the database, that is when the error pops up indicating that the string
is empty. Thus the session variable is empty. So yes you are right it will
print a blank string but when using it to open a database problems will
occur and that is where my problem is currently.

Thanks,
Shahid
 
R

Ray Costanzo [MVP]

What is popping up an error?

Ray at work

Shahid Juma said:
Yes I have placed it in the root. When I try to use the connectionstring
to
open the database, that is when the error pops up indicating that the
string
is empty. Thus the session variable is empty. So yes you are right it will
print a blank string but when using it to open a database problems will
occur and that is where my problem is currently.

Thanks,
Shahid
 
S

Shahid Juma

The problem has been fixed after following some of the steps that were
outlined.

Shahid
 
S

Stephanie Stowe

Look in IIS. If the application root appears as a regular folder instead of
the other funky icon (I think it is supposed to be an open box with a globe
and a document coming out), it is probably not set up as an "application."
Right click on the app root and select properties. Next to Application name,
click the create button.

This tells IIS to fire the events in global.asa. I have seen the events
sometimes fire anyway, even when this is not set. But then, I have also seen
it not.

If that is not the problem, can you tell me what you are writing the code
in? Interdev? Notepad? That will help determine what is in your
troubleshooting toolbox, so to speak.

S
 
S

Stephanie Stowe

The string is empty is not the same as the object/session does not exist. In
the same code you gave


Sub Session_OnStart
Session("ConnectionString") = ""
Session("ConnectionTimeout") = 15
Session("CommandTimeout") = 30
End Sub

Observe that the string IS empty.

You may want to give the exact code at the line of the error as well as the
exact error.
 

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

Similar Threads


Members online

No members online now.

Forum statistics

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

Latest Threads

Top