Article ID: 173307
Article Last Modified on 5/2/2006
Child 1 app state held Child 2 app state held
Root app called first No No
Root app called before Child 1 only No Yes
Root app called before Child 2 only Yes No
Root app called last Yes Yes
NOTE: There is a registry entry, CheckForNestedVroots(Default = 1), that ASP uses to check for nested virtual roots so that if a new nested virtual root is created while the system is running, the running
application sees the new nested Global.asa file as soon as it is
saved. From this registry parameter you can infer that ASP is
designed to check for Global.asa files in subdirectories.
However, this behavior works in only one case: If all nested
applications start before the root application, ASP checks for
Global.asa files in all linked applications (both above and at the
same level of the calling application). However, if the
root application is called first or called before any nested
application, only the root application's session state (sessionid and
session variables) is maintained; it is not as if ASP does not check for
nested virtual roots.
C:\InetPub\wwwroot <Home>
Global.asa
C:\InetPub\wwwroot\Test2 (Nested)
Global.asa
C:\InetPub\wwwroot\Test2\Test3 (Nested)
Global.asa
C:\InetPub\wwwroot\Test4
Global.asa
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
Application("MyTestApplication") = "WWWRoot: Welcome to _
Application Level Scope!"
Application("WWWRoot") = "Chickens Eat..."
Response.Write("Fire Application_OnStart for WWWRoot" & "<br>")
End Sub
Sub Session_OnStart
Session("MyTestSession") = "WWWRoot: Welcome to session
level scope!"
Session("SessionID") = Session.SessionID
Session("WWWRoot") = "Chicken Food!"
Response.Write("Fire Session_OnStart for WWWRoot" & "<br>")
End Sub
</SCRIPT>
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html;
charset=iso-8859-1">
<TITLE>Test Nested Virtual Roots</TITLE>
</HEAD>
<BODY>
<%
Response.Write("Common Variable Names:" & "<br>")
Response.Write Application("MyTestApplication") & "<br>"
Response.Write Session("MyTestSession") & "<br>"
Response.Write "Session.SessionID = " &
Session("SessionID") & "<br><p>"
Response.Write("Application Scoped Variables:" & "<br>")
Response.Write "WWWRoot: " & Application("WWWRoot") & "<br>"
Response.Write "WWWTest2: " & Application("WWWTest2") & "<br>"
Response.Write "WWWTest3: " & Application("WWWTest3") & "<br>"
Response.Write "WWWTest4: " & Application("WWWTest4") & "<br><p>"
Response.Write("Session Scoped Variables:" & "<br>")
Response.Write "WWWRoot: " & Session("WWWRoot") & "<br>"
Response.Write "WWWTest2: " & Session("WWWTest2") & "<br>"
Response.Write "WWWTest3: " & Session("WWWTest3") & "<br>"
Response.Write "WWWTest4: " & Session("WWWTest4") & "<br><p>"
%>
<BR>
<P>
<A
HREF=<WWLINK TYPE="GENERIC" VALUE="http://<%=Request.ServerVariables("SERVER_NAME")%>/WWWTest2/>_">http://<%=Request.ServerVariables("SERVER_NAME")%>/WWWTest2/>_</WWLINK>
Click here to go to WWWTest2</A><BR>
<A
HREF=<WWLINK TYPE="GENERIC" VALUE="http://<%=Request.ServerVariables("SERVER_NAME")%>/WWWTest3/>_">http://<%=Request.ServerVariables("SERVER_NAME")%>/WWWTest3/>_</WWLINK>
Click here to go to WWWTest3>/A><BR>
<A
HREF=<WWLINK TYPE="GENERIC" VALUE="http://<%=Request.ServerVariables("SERVER_NAME")%>/WWWTest4/>_">http://<%=Request.ServerVariables("SERVER_NAME")%>/WWWTest4/>_</WWLINK>
Click here to go to WWWTest4>/A><BR>
</BODY>
</HTML>
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
Application("MyTestApplication") = "WWWTest2: Welcome to _
Application Level Scope!"
Application("WWWTest2") = "Dogs Eat..."
Response.Write("Fire Application_OnStart for WWWTest2" & "<br>")
End Sub
Sub Session_OnStart
Session("MyTestSession") = "WWWTest2: Welcome to session_
level scope!"
Session("SessionID") = Session.SessionID
Session("WWWTest2") = "Dog Food!"
Response.Write("Fire Session_OnStart for WWWTest2" & "<br>")
End Sub
</SCRIPT>
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html;
charset=iso-8859-1">
<TITLE>Test Nested Virtual Roots</TITLE>
</HEAD>
<BODY>
<%
Response.Write("Common Variable Names:" & "<br>")
Response.Write Application("MyTestApplication") & "<br>"
Response.Write Session("MyTestSession") & "<br>"
Response.Write "Session.SessionID = " & Session("SessionID")
& "<br><p>"
Response.Write("Application Scoped Variables:" & "<br>")
Response.Write "WWWRoot: " & Application("WWWRoot") & "<br>"
Response.Write "WWWTest2: " & Application("WWWTest2") & "<br>"
Response.Write "WWWTest3: " & Application("WWWTest3") & "<br>"
Response.Write "WWWTest4: " & Application("WWWTest4") & "<br><p>"
Response.Write("Session Scoped Variables:" & "<br>")
Response.Write "WWWRoot: " & Session("WWWRoot") & "<br>"
Response.Write "WWWTest2: " & Session("WWWTest2") & "<br>"
Response.Write "WWWTest3: " & Session("WWWTest3") & "<br>"
Response.Write "WWWTest4: " & Session("WWWTest4") & "<br><p>"
%>
<BR>
<P>
<A
HREF=http://<%=Request.ServerVariables("SERVER_NAME")%>/WWWRoot/>_
Click here to go to WWWRoot</A><BR>
<A
HREF=http://<%=Request.ServerVariables("SERVER_NAME")%>/WWWTest3/>_
Click here to go to WWWTest3</A><BR>
<A
HREF=http://<%=Request.ServerVariables("SERVER_NAME")%>/WWWTest4/>_
Click here to go to WWWTest4</A><BR>
</BODY>
</HTML>
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
Application("MyTestApplication") = "WWWTest3: Welcome to _
Application Level Scope!"
Application("WWWTest3") = "Cows Eat..."
Response.Write("Fire Application_OnStart for WWWTest3" & "<br>")
End Sub
Sub Session_OnStart
Session("MyTestSession") = "WWWTest3: Welcome to session_
level scope!"
Session("SessionID") = Session.SessionID
Session("WWWTest3") = "Cow Food!"
Response.Write("Fire Session_OnStart for WWWTest3" & "<br>")
End Sub
</SCRIPT>
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html; _
charset=iso-8859-1">
<TITLE>Test Nested Virtual Roots</TITLE>
</HEAD>
<BODY>
<%
Response.Write("Common Variable Names:" & "<br>")
Response.Write Application("MyTestApplication") & "<br>"
Response.Write Session("MyTestSession") & "<br>"
Response.Write "Session.SessionID = " & Session("SessionID") & "
<br><p>"
Response.Write("Application Scoped Variables:" & "<br>")
Response.Write "WWWRoot: " & Application("WWWRoot") & "<br>"
Response.Write "WWWTest2: " & Application("WWWTest2") & "<br>"
Response.Write "WWWTest3: " & Application("WWWTest3") & "<br>"
Response.Write "WWWTest4: " & Application("WWWTest4") & "<br><p>"
Response.Write("Session Scoped Variables:" & "<br>")
Response.Write "WWWRoot: " & Session("WWWRoot") & "<br>"
Response.Write "WWWTest2: " & Session("WWWTest2") & "<br>"
Response.Write "WWWTest3: " & Session("WWWTest3") & "<br>"
Response.Write "WWWTest4: " & Session("WWWTest4") & "<br><p>"
%>
<BR>
<P>
<A
HREF=http://<%=Request.ServerVariables("SERVER_NAME")%>/WWWRoot/>_
Click here to go to WWWRoot</A><BR>
<A HREF=http://<%=Request.ServerVariables("SERVER_NAME")%>/WWWTest2/>
Click_ here to go to WWWTest2</A><BR>
<A
HREF=http://<%=Request.ServerVariables("SERVER_NAME")%>/WWWTest4/>
Click here to go to WWWTest4</A><BR>
</BODY>
</HTML>
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
Application("MyTestApplication") = "WWWTest4: Welcome to _
Application Level Scope!"
Application("WWWTest4") = "Tony Drinks..."
Response.Write("Fire Application_OnStart for WWWTest4" & "<br>")
End Sub
Sub Session_OnStart
Session("MyTestSession") = "WWWTest4: Welcome to session_
level scope!"
Session("SessionID") = Session.SessionID
Session("WWWTest4") = "Good Wine!"
Response.Write("Fire Session_OnStart for WWWTest4" & "<br>")
End Sub
</SCRIPT>
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual InterDev 1.0">
<META HTTP-EQUIV="Content-Type" content="text/html;_
charset=iso-8859-1">
<TITLE>Test Nested Virtual Roots</TITLE>
</HEAD>
<BODY>
<%
Response.Write("Common Variable Names:" & "<br>")
Response.Write Application("MyTestApplication") & "<br>"
Response.Write Session("MyTestSession") & "<br>"
Response.Write "Session.SessionID = " & Session("SessionID") &
"<br><p>"
Response.Write("Application Scoped Variables:" & "<br>")
Response.Write "WWWRoot: " & Application("WWWRoot") & "<br>"
Response.Write "WWWTest2: " & Application("WWWTest2") & "<br>"
Response.Write "WWWTest3: " & Application("WWWTest3") & "<br>"
Response.Write "WWWTest4: " & Application("WWWTest4") & "<br><p>"
Response.Write("Session Scoped Variables:" & "<br>")
Response.Write "WWWRoot: " & Session("WWWRoot") & "<br>"
Response.Write "WWWTest2: " & Session("WWWTest2") & "<br>"
Response.Write "WWWTest3: " & Session("WWWTest3") & "<br>"
Response.Write "WWWTest4: " & Session("WWWTest4") & "<br><p>"
%>
<BR>
<P>
<A
HREF=http://<%=Request.ServerVariables("SERVER_NAME")%>/WWWRoot/>
Click here to go to WWWRoot</A><BR>
<A
HREF=http://<%=Request.ServerVariables("SERVER_NAME")%>/WWWTest2/>
Click here to go to WWWTest2</A><BR>
<A
HREF=http://<%=Request.ServerVariables("SERVER_NAME")%>/WWWTest3/>
Click here to go to WWWTest3</A><BR>
</BODY>
</HTML>
Keywords: kbwebserver kbstate kbprb KB173307