ASP 3.0 - Server.Execute 问题:遭受“ASP 健忘症"之苦 [英] ASP 3.0 - Server.Execute Problems: Suffering from "ASP Amnesia"

查看:14
本文介绍了ASP 3.0 - Server.Execute 问题:遭受“ASP 健忘症"之苦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建了两个 ASP 3.0 文件:-Main.asp-Colors.asp

Created Two ASP 3.0 Files: -Main.asp -Colors.asp

<%

Blah Blah Blah...

If sColor = true then
Server.Execute "Colors.asp"
End If
'If sColor is true, Pops over to Colors.asp
'Then pops right back over to here again

'Once back here again, it has no idea what
'sRed or sBlue was at all...it's as if has
'been "blank slated"...sRed? Who the heck is sRed?

If sRed then
Response.Write "Color is Red"
End If
'Does not work...skips right over...
'Who is sRed? What is sRed?
'Oh well, keep on truckin'

%>

<小时>

颜色.asp

<%
Dim sRed
sRed = instr(sString, "Red") >0

Dim sBlue
sBlue = instr(sString, "Blue") >0

Dim sGreen
sGreen = instr(sString, "Green") >0

%>

<小时>

如果要进入 Colors.asp 文件并修改/追加如下:

%>


If one were to go into the Colors.asp file above and modify/append it to read as follows:

<%
Dim sRed
sRed = instr(sString, "Red") >0

Dim sBlue
sBlue = instr(sString, "Blue") >0

Dim sGreen
sGreen = instr(sString, "Green") >0

If sRed then
Response.Write "Color is Red"
End If

%>

人们会收到一个带有颜色为红色"的屏幕当 sColor 在 Main.asp 和 sString 上为真时包含红色".所以我知道她正在过去,并返回到 Main.asp ......但不知何故她对这些变量一无所知:sRed,sBlue,或在 Colors.asp.Once 她变暗的 sGreen回到 Main.asp,她一无所知.

One would receive a screen with "Color is Red" when sColor was true over at Main.asp and sString contained "Red." So I know she's getting over there, and also returning back over to Main.asp...but somehow she has no clue about those variables: sRed, sBlue, or sGreen that were dimmed over at Colors.asp.Once she get's back over to Main.asp she's clueless.

什么给了?为什么她得了 ASP 失忆症刚刚在 Colors.asp 结束后返回 Main.asp?

What gives? Why does she have ASP Amnesia once she gets back to Main.asp after having just been over at Colors.asp?

顺便说一句,我曾经有一个表现相同的女朋友.那么在 Colors.asp 上会有什么 ASP 手帕?

BTW, I used to have a girlfriend that acted the same way. So what kinda ASP hanky panky's goin' on over at Colors.asp?

请帮忙!

ASP 小便

推荐答案

执行页面无法访问调用页面中的局部变量,反之,调用页面也无法访问执行页面中的局部变量.无论您是否声明它们都没有区别,这两个脚本不在相同的上下文中执行,更不用说相同的范围了.

The executed page has no access to local variables in the calling page and conversely neither does the calling page have access to local variables in the executed page. Whether you declare them or not makes no difference the two scripts are not executing in the same context let alone the same scope.

调用 Server.Execute() 有效地导致被执行的页面被隔离执行,并且它的输出在调用页面的输出被合并到它被调用的点:

Calling Server.Execute() effectively causes the executed page to be executed in isolation and its output incorporated into the output of the calling page at the point it is called:

IIS 处理 .asp 文件后在输入参数中指定Server.Execute,响应为返回到调用 ASP 脚本.

After IIS processes the .asp file specified in the input parameter to Server.Execute, the response is returned to the calling ASP script.

以下集合和属性可用于执行的 ASP 页面:

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.

如果调用中包含文件页面使用#include,执行的.asp 不会使用它.例如,你文件中可能有一个子例程包含在您的呼叫页面中,但执行的 .asp 将无法识别子程序名称.您必须包括每个执行的 .asp 中的文件需要子程序.

If a file is included in the calling page by using #include, the executed .asp will not use it. For example, you may have a subroutine in a file that is included in your calling page, but the executed .asp will not recognize the subroutine name. You must include the file in each executed .asp that requires the subroutine.

如果您想在脚本之间进行变量传递,最好使用包含指令.如果您必须进行变量传递,那么您将不得不使用 ApplicationSession 对象来判断某些东西,我不建议这样做.

If you want to do variable passing between scripts you are much better off using include directives. If you must do variable passing then you will have to jury rig something using the Application or Session object and I would not advise that.

这篇关于ASP 3.0 - Server.Execute 问题:遭受“ASP 健忘症"之苦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆