Passing a parameter through server.execute?

后端 未结 4 849
南笙
南笙 2021-01-12 09:34

It is possible to pass a parameter through server.execute?

Fx. I have in my site.asp an IF-scenario where I need functions.asp?a=some

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-12 09:43

    You can't use querystring in Server.Execute, it's clearly mentioned in the official documentation.

    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:

    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
    

    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.

    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"
    

    And then:

    if Session("a") = "something" and Session("id") > 100 then
        response.write("Yes way dude")
    else  
        response.write("No way dude")
    end if
    

提交回复
热议问题