开发者

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜