title: Progressively stream the output of an ASP.NET page - or render a page outside of an HTTP request
body: <p>I have an ASP.NET 2.0 page with many repeating blocks, including a third-party server-side control (so it's not just plain HTML). Each is quite expensive to generate, in terms of both CPU and RAM. I'm currently using a standard Repeater control for this.</p>
  
  <p>There are two problems with this simple approach:</p>
  
  <ol>
  <li>The entire page must be rendered before any of it is returned to the client, so the user must wait a long time before they see any data. (I write progress messages using <code>Response.Write</code>, so there is <em>feedback</em>, but no actual results.)</li>
  <li>The ASP.NET worker process must hold everything in memory at the same time. There is no inherent needs for this: once one block is processed it won't be changed, so it could be returned to the client and the memory could be freed.</li>
  </ol>
  
  <p>I would like to somehow return these blocks to the client one at a time, as each is generated. I'm thinking of extracting the stuff inside the Repeater into a separate page and getting it repeatedly using AJAX, but there are some complications involved in that and I wonder if there is some simper approach. Ideally I'd like to keep it as one page (from the client's point of view), but return it incrementally.</p>
  
  <p>Another way would be to do something similar, but on the server: still create a separate page, but have the <em>server</em> access it and then <code>Response.Write()</code> the HTML it gets to the response stream for the <em>real</em> client request. Is there a way to avoid an HTTP request here, though? Is there some ASP.NET method that would render a UserControl or a Page outside of an HTTP request and simply return the HTML to me as a string?</p>
  
  <p>I'm open to other ideas on how to do this as well.</p>