PRB: Global.asa Reports "Element Not Found" Error (275519)



The information in this article applies to:

  • Microsoft Active Server Pages

This article was previously published under Q275519

SYMPTOMS

When you use the Active Server Pages (ASP) Request.ServerVariables collection in the Application events defined in the Global.asa file, you may receive the following error message:
(0x8002802B)
Element not found.
global.asa, line xx
NOTE: In the error message above, xx varies depending on how the code has been written.

CAUSE

The Request.ServerVariables collection is not available in the Application events of the Global.asa file. The Application events include the Application_OnStart and the Application_OnEnd procedures.

RESOLUTION

To work around this issue, access the Request.ServerVariables collection in the Session events of the Global.asa file. The Session events include the Session_OnStart and the Session_OnEnd procedures. To make your code run only when the application starts or ends, you can add the following code to the Global.asa file:
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
  Application("txtOnStart") = true
End Sub

Sub Session_OnStart
  if Application("txtOnStart") = true then
    Application("txtPathInfo") = Request.ServerVariables("PATH_INFO")
    Application("txtInstanceId") = Request.ServerVariables("INSTANCE_ID")
    Application("txtOnStart") = false
  end if
End Sub
</SCRIPT>
				

MORE INFORMATION

Steps to Reproduce Behavior

To reproduce this behavior, add the following code to the Global.asa file:
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
  Application("txtPathInfo") = Request.ServerVariables("PATH_INFO")
End Sub
</SCRIPT>
				

Modification Type:MajorLast Reviewed:5/8/2001
Keywords:kbASPObj kbCodeSnippet kbDSupport kbprb kbScript KB275519