views:

64

answers:

1

Hi all, In Classic ASP, shouldn't a subroutine in global.asa be available to all .asp pages in the application? For some reason I am having trouble calling the sub. Before I look at whether something specific to my application is causing the problem I wanted to make sure I understood properly.

global.asa:

<SCRIPT LANGUAGE="VBScript" RUNAT="Server">
  sub foo
    session("foo") = true
  end sub
</SCRIPT>

myinclude.inc, included in all pages:

call foo

I get 'Type Mismatch' runtime error referencing foo. Am I totally misunderstanding this?

+1  A: 

You can't declare global functions like that. To quote the documenation:

Procedures declared in the Global.asa file can be called only from one or more of the scripts associated with the Application_OnStart, Application_OnEnd, Session_OnStart, and Session_OnEnd events. They are not available to the ASP pages in the ASP-based application.

Cheran S
Thanks, you're right. I was able to include some code on every page to do what I wanted to do, so no matter which page was the first one requested my code runs.
Don Zacharias