问题描述
可以通过server.execute
传递参数吗?
外汇.我的 site.asp
中有一个 IF 场景,我需要在其中执行 functions.asp?a=something&id=123
.这可能吗?!
Fx. I have in my site.asp
an IF-scenario where I need functions.asp?a=something&id=123
executed. Is this possible?!
在site.asp:
dim id
id = 123
if b = "hi" then
server.execute("functions.asp?a=something&id=" & id)
else
response.write("No way dude")
end if
关于functions.asp
On functions.asp
a = request.querystring("a")
id = request.querystring("id")
if a = "something" and cint(id) > 100 then
response.write("Yes way dude")
else
response.write("No way dude")
end if
推荐答案
Server.Execute
中不能使用querystring,官方文档.
You can't use querystring in Server.Execute
, it's clearly mentioned in the official documentation.
你能做的更好:你可以在functions.aspsite.asp
中定义的变量id
>,你也可以声明和设置另一个变量,a
:
What you can do is much better: you can directly access the variable id
defined in site.asp
inside functions.asp
, and you can also declare and set another variable, a
:
--site.asp:
--site.asp:
dim id, a
id = 123
a = "something"
server.execute("functions.asp")
--functions.asp
--functions.asp
if a = "something" and cint(id) > 100 then
response.write("Yes way dude")
else
response.write("No way dude")
end if
当它创建全新的脚本环境"时,执行的文件将无法访问调用代码属性、方法或变量,只能访问全局请求参数、会话等.
As it creates whole new "scripting environment" the executed file won't have access to the calling code properties, methods or variables, only to the global Request parameters, Session etc.
考虑到这一点,我担心最简单的方法是使用 Session 变量在页面之间传递值:
With this in mind, I fear the most simple way around is using Session variable to pass the value between pages:
Session("id") = 123
Session("a") = "something"
然后:
if Session("a") = "something" and Session("id") > 100 then
response.write("Yes way dude")
else
response.write("No way dude")
end if
这篇关于通过 server.execute 传递参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,WP2