Don Zacharias
Don Zacharias

Reputation: 1564

Call a subroutine/function in Global.asa from an ASP page?

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?

Upvotes: 1

Views: 2882

Answers (1)

Cheran Shunmugavel
Cheran Shunmugavel

Reputation: 8459

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.

Upvotes: 2

Related Questions