This question may be old and resolved, but the best answer does not mention everything, and it has information published on Microsoft.com:
Server.Execute Method
The following collections and properties are available on the executed ASP page:
- Application variables , even if installed on the calling page.
- Session properties , even if they are set on the calling page.
- Server variables and properties , even if they are set on the calling page.
- Request collections and properties , even if they are set on the calling page. This includes Form and QueryString data passed to the calling page.
- Collections of responses and properties . The executed .asp file can modify the HTTP headers. However, as with any .asp file, if the .asp executable tries to change the HTTP headers after sending the response to the client, it generates an error.
So, as you can see, there are five ways in which Microsoft suggests passing variables using the Server.Execute method. Before I saw this at Microsoft, the preferred method was Session , as the best answer suggests, as I saw this before the information on Microsoft.com. But having noticed that QueryStrings can be passed from the previous page, I would have to say this using Session to pass values. Session required if your application needs to add variables to the execution page.
But by passing variables, I would say QueryStrings , and this is easy to apply if your application allows flexibility. I'm sure you know how to use querystrings already, but in the sense of using it for the Server.Execute method Server.Execute you can simply do this:
Consider ASP1.asp and ASP2.asp :
ASP1.asp includes:
Server.Execute("ASP2.asp")
ASP2.asp includes:
Response.Write Request("id")
When you call ASP1.asp?id=123 you will notice that ASP2.asp also sees the same Querystring passed to ASP1.asp, so it would write 123 in ASP1.asp's response.
This is much less complicated than using Session for a task.
source share