title: Dynamic Page Rendering in ASPX
body: <p>I'm very new to C# and .NET and I find myself faced with a problem and I'm not sure in which direction I need to head.</p>
  
  <p>My company works with a third party subscription fulfillment system for many functions, including billing and renewals. This system has the capability of automatically sending an email when certain events are triggered. For example, each subscription goes through, what we call, a renewal series. This series consists of several efforts spread accross the life of the subscription.</p>
  
  <p>When a subscription qualifies for a certain effort of this series, we can have an event generated that will cause the system to send a HTTP POST request to a given URI with an XML payload. The endpoint (an .aspx page) receives the request, processes it, and returns a response with, in this case, HTML code.  That HTML is then emailed out by the fulfillment system.</p>
  
  <p>I have a basic web application created with a few of these .aspx pages up and running.  Each page has a corresponding .cs code behind file.</p>
  
  <p>Here's where my question really starts. In our fulfillment system, we can only define one endpoint per combination of event and product. So, no matter which effort a subscription is qualifying for at the time, the event itself is the same. What is different, though, is the XML of the HTTP POST request. It's in that XML that I can tell for which effort the request has been generated. The reason that is important is because the HTML of the corresponding email is different for each effort. To phrase it a slightly different way, the HTML that should be rendered is different, top to bottom, for effort 1 than effort 2. Effort 2 is different than effort 3, and so on.</p>
  
  <p>So, what I'm trying to figure out is how to "direct the traffic". Since all of these requests will come to a single endpoint, I need to dynamically return the correct HTML for the corresponding effort.</p>
  
  <p>In a different .aspx page in this same app, there is some content that needs to be generated dynamically depending on the contents of the request. In that case, I used two <code>PlaceHolder</code> controls, one for each possible set of text.  Then, in the code behind, set their <code>Visible</code> property to true or false as needed.</p>
  
  <p>I dismissed the idea of doing that in this case early on since there are five or six HTML templates and stuffing all of them into one page would be messy and hard to maintain.</p>
  
  <p>This is where I'm at the point that I don't know what to do next. I have a feeling that a User Control or Custom Control is going to be the way to go? But, is plain old redirection a better option? Or none of the above?</p>