ASP 101 - Active Server Pages 101 - Web03
The Place ASP Developers Go!

Please visit our partners


Windows Technology Windows Technology
15 Seconds
4GuysFromRolla.com
ASP 101
ASP Wire
VB Forums
VB Wire
WinDrivers.com
internet.commerce internet.commerce
Partners & Affiliates














ASP 101 is an
internet.com site
ASP 101 is an internet.com site
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers

ASP 101 News Flash ASP 101 News Flash





Script Output:

This text is right before the call to Server.Execute.

This text is in the server_target.asp file, but remember that the context from the calling page is passed when the target file is executed. That means that calls to things like Request.ServerVariables("SCRIPT_NAME") may not return the value you might expect.

Request.ServerVariables("SCRIPT_NAME"): /samples/server_execute.asp

Even though the line of code being executed is actually located in server_target.asp, it's still running in the context of the original page which, in this case, is server_execute.asp.

This text is right after the call to Server.Execute.


ASP HTML Download            FAQ

The target script ("server_target.asp")

 ASPDownload

ASP.NET Version

If you've been using ASP for any length of time, you've almost certainly used Response.Redirect to move a user from one page to another. While Response.Redirect gets the job done, it unfortunately requires a round trip to the client browser. While there are some situations where this is necessary, more often then not you can accomplish the task more efficiently using Server.Execute.

While Response.Redirect accomplishes its task by telling the browser to look elsewhere, Server.Execute does its work on the server by simply transferring execution to the script passed to it as a parameter. When that script finishes execution, control returns to the calling page. For example, this page is called server_execute.asp. While the sentences before and after the green section are in this file, the green section itself is actually contained in the file server_target.asp. Notice that while server_target.asp was executed, your browser never left server_execute.asp like it would have if we'd used Response.Redirect.

One important note is that while execution passes from server_execute.asp to server_target.asp and back, the page context remains the same. What this means is that calls to things like Request.ServerVariables("SCRIPT_NAME") will continue to return server_execute.asp even if they are actually in the server_target.asp file. Similarly, if you transfer execution to a different directory, the client browser won't know that so things like <img> tags in the target script may need to be adjusted so that the browser can still find the intended targets.


Samples

Home |  News |  Samples |  Articles |  Lessons |  Resources |  Forum |  Links |  Search |  Feedback

Internet.com
The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers