Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Execute Method (String, TextWriter)
Collapse the table of content
Expand the table of content

HttpServerUtility.Execute Method (String, TextWriter)

.NET Framework 1.1

Executes the current request using another page at the specified URL. A TextWriter captures output from the page.

[Visual Basic]
Overloads Public Sub Execute( _
   ByVal path As String, _
   ByVal writer As TextWriter _
)
[C#]
public void Execute(
 string path,
 TextWriter writer
);
[C++]
public: void Execute(
 String* path,
 TextWriter* writer
);
[JScript]
public function Execute(
   path : String,
 writer : TextWriter
);

Parameters

path
The URL path of the new page.
writer
The TextWriter to capture the output.

Exceptions

Exception Type Condition
HttpException The child process could not be executed.

Remarks

The Execute method continues execution of the original page after execution of the new page is completed. The Transfer method unconditionally transfers execution to another page.

Example

The following example executes the aspx page "Login.aspx" on the server in the current directory and receives the output from the page through the StringWriter object writer. It writes the HTML stream received from writer to the HTTP output stream.

[Visual Basic] 
Dim writer As New StringWriter
Server.Execute("Login.aspx", writer)
Response.Write("<H3>Please Login:</H3><br>" & writer.ToString())
   

[C#] 
StringWriter writer = new StringWriter();
Server.Execute("Login.aspx", writer);
Response.Write("<H3>Please Login:</H3><br>"+ writer.ToString());
   

[C++] 
StringWriter* writer = new StringWriter();
Server->Execute(S"Login.aspx", writer);
Response->Write(String::Format(S"<H3>Please Login:</H3><br>{0}", writer));
   

[JScript] 
var writer : StringWriter = new StringWriter()
Server.Execute("Login.aspx", writer)
Response.Write("<H3>Please Login:</H3><br>" + writer.ToString())
   

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

See Also

HttpServerUtility Class | HttpServerUtility Members | System.Web Namespace | HttpServerUtility.Execute Overload List

Show:
© 2015 Microsoft