Asp-Classic
通過 server.execute 傳遞參數?
可以傳遞參數
server.execute嗎?外匯。我有一個需要執行
site.asp的 IF 場景。functions.asp?a=something&id=123這可能嗎?!在 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
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中明確提到。你可以做的更好:你可以直接訪問裡面
id定義的變數,你也可以聲明和設置另一個變數,:site.asp``functions.asp``a–site.asp:
dim id, a id = 123 a = "something" server.execute("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當它創建全新的“腳本環境”時,執行的文件將無法訪問呼叫程式碼屬性、方法或變數,只能訪問全域請求參數、會話等。
考慮到這一點,我擔心最簡單的方法是使用 Session 變數在頁面之間傳遞值:
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