How to load parsed aspx into string variable
<p>I am attempting to load a parsed aspx file into a string. The reason for this is because I have a page with a fair amount of html on it which also has sections that need to be processed in order to insert the correct information. This page then needs to be displayed as a confirmation page as well sent in a confirmation email when the user submits a form.</p>

<p>Displaying the confirmation page is simple enough, but my idea to prevent code duplication is to render the aspx file to a string variable to use as the content of the email as well.</p>

<p>I realize that I could add all the content as a huge multi-line string and load it onto the aspx page, and then into the email, but this solution feels messy to me and will require an application re-compile should I ever want to change the content.</p>

<p>Perhaps somebody can suggest a better way to achieve what I am attempting?</p>

<p>The code I have come up with is below, but I am nit sure if it is possible to somehow catch the output from ProcessRequest before it gets sent to the browser:</p>

<pre><code>IHttpHandler handler = PageParser.GetCompiledPageInstance("/SubmitConfirmation.aspx?appid=" + this.Id, "SubmitConfirmation.aspx", HttpContext.Current);
handler.ProcessRequest(HttpContext.Current);
string str_out = ???;
</code></pre>

<p>Basically what I am trying to achieve is the same as the following PHP code would do:</p>

<pre><code>&lt;?php
ob_start();
include("SubmitConfirmation.php");
$str_out = ob_get_contents();
ob_end_clean();
?&gt;
</code></pre>

<p>Any suggestions are welcome.</p>
