Basic Questions about Global.asa from a beginner

M

Mukesh_Singh_Nick

I am learning classic ASP 3.0. Below are my questions:

1. Do we have to include (<!-- #include FILE="global.asa" -->) the
global.asa file into every .asp page? I am doing the examples in
Windows Notepad and not in DreamWeaver or InterDev. Or, does IIS
automatically associate global.asa, if one is present in the
application folder, with the pages in that folder?

2. Can we write other global functions that we intend to use accross
pages in an application in the global.asa file? 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())
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
 
E

Evertjan.

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" -->
 

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

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top