wrote on 17 sep 2006 in microsoft.public.inetserver.asp.general:
I am learning classic ASP 3.0. Below are my questions:
1. Do we have to include (<!-- #include FILE="global.asa" -->)
No, it wouldn't even run.
the
global.asa file into every .asp page? I am doing the examples in
Windows Notepad and not in DreamWeaver or InterDev.
Very good, using a text editor is the best way to learn ASP, HTML and
other code.
Or, does IIS
automatically associate global.asa, if one is present in the
application folder, with the pages in that folder?
No.
global.asa runs only when the ASP application starts, restarts, or when
the apication sees that it is changed.
So global.asa does not run at the beginning of a session!
However session_nstart is invoked at every session start.
2. Can we write other global functions that we intend to use accross
pages in an application in the global.asa file?
No, global.asa only lets you set application variables and session
variables.
I have done so but when
I call the method in a login.asp page, I get a TypeMismatch.
For e.g in login.asp
<%
Response.Write(CallMe())
unnecesary () if you use vbscript.
Response.End
%>
In global.asa
Sub Application_onStart()
End Sub
...
....etc. (application and session events)
Public Function CallMe()
CallMe = "Did you just call me?"
End Sub
So you knew this already ;-{
Try:
Sub Application_onStart()
application("CallMe") = "Did you just call me?"
End Sub
<%
Response.Write application("CallMe")
Response.End
%>
=============
If you want to have standard functions present on your pages,
include them:
<!-- #include virtual="/myLibrary/myFunctionsInclude.asp" -->
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)