ASP Server.Execute - 已执行页面未从 former/first 页面访问变量
ASP Server.Execute - Executed Page is not accessing variables from the former/first page
我已经知道 Server.Execute(..) 不接受查询字符串。 MSDN 网站说,前一个网站的所有变量都可用于执行页面。但是它根本不适合我。知道为什么吗?
应该有效但无效的简单示例:
<%
Dim strVar
strVar = "This Text"
Server.Execute("page2.asp")
%>
Page2.asp
<%
Response.Write( strVar )
%>
知道为什么这不起作用吗?
ps。我没有使用“< !--include .. -->”因为我有条件输出。
使用 Server.Execute 时,第 1 页中的变量在第 2 页上不可用,因此按照设计,您的示例不应工作。
这是 MSDN page for Server.Execute 中的一个片段,解释了第 2 页上第 1 页的可用内容。
The following collections and properties are available to the executed
ASP page:
- Application variables, even if they are set in the calling page.
- Session properties, even if they are set in the calling page.
- Server variables and properties, even if they are set in the calling page.
- Request collections and properties, even if they are set in the calling page. This includes Form and QueryString data passed to the calling page.
- Response collections and properties. The executed .asp file may modify HTTP headers. However, as with any .asp file, if the executed .asp file attempts to modify HTTP headers after it sends a response to the client, it generates an error.
我已经知道 Server.Execute(..) 不接受查询字符串。 MSDN 网站说,前一个网站的所有变量都可用于执行页面。但是它根本不适合我。知道为什么吗?
应该有效但无效的简单示例:
<%
Dim strVar
strVar = "This Text"
Server.Execute("page2.asp")
%>
Page2.asp
<%
Response.Write( strVar )
%>
知道为什么这不起作用吗?
ps。我没有使用“< !--include .. -->”因为我有条件输出。
使用 Server.Execute 时,第 1 页中的变量在第 2 页上不可用,因此按照设计,您的示例不应工作。
这是 MSDN page for Server.Execute 中的一个片段,解释了第 2 页上第 1 页的可用内容。
The following collections and properties are available to the executed ASP page:
- Application variables, even if they are set in the calling page.
- Session properties, even if they are set in the calling page.
- Server variables and properties, even if they are set in the calling page.
- Request collections and properties, even if they are set in the calling page. This includes Form and QueryString data passed to the calling page.
- Response collections and properties. The executed .asp file may modify HTTP headers. However, as with any .asp file, if the executed .asp file attempts to modify HTTP headers after it sends a response to the client, it generates an error.