title: Create Dynamic View with static HTML in MVC
body: <p>I have been researching dynamic content for MVC views and partial views but have not successfully found an architecture to fit my needs.</p>
  
  <p>Basically I am required to create a landing page based on parameters pass by the URL.
  For basics
  <a href="http://mydns.com/myconroller/myview/?landingpage=Param1" rel="nofollow">http://mydns.com/myconroller/myview/?landingpage=Param1</a></p>
  
  <p>The controller will need to find the HTML that will be used to create the view.
  The view is going to be different based on the landing page.
  (for the sake of the question, I am using landingpage as an example)
  My goal is to be able to deploy a Landing page and based on the URL use that HTML Landing page in the view based on the landingpage parameter that is passed.</p>
  
  <p>There are other views that are working currently in the controller.  I am trying to add functionality to be able to add a new one time page without having to recompile.</p>
  
  <p>I have searched through various ideas on how to load dynamic views but cannot seem to find a solution that fits this need based on what I have read.</p>
  
  <p>I can possibly RedirectToAction but I am still in the dark on where to deploy and I am getting several problems with Razor as it is not in the shared directory and then I am stuck with deployment issues as I want to organize the landing pages differently than I am organizing the views.</p>
  
  <p><strong>Solution:</strong>
  I decided to take a different approach and use the ContentResult Action in the controller.  I still have the Main View and I use the HTML extensions to render the HTML pages that I have deployed in my customer's directory.</p>
  
  <pre><code>@{
    Html.RenderAction("LandingPageContent", "Controller", Model);
  }
  </code></pre>
  
  <p>Then in the controller I load the HTML directly and return the ContentResult</p>
  
  <pre><code>public ContentResult LandingPageContent(object model, FormCollection collection)
  {
    MySRCHelper helper = new MySRCHelper();
    ContentVariables variables = helper.getContentSRC(model.EntryCode);
    model.ContentSRC = variables.LandingPageSRC;
  
    return Content(System.IO.File.ReadAllText(Server.MapPath(model.ContentSRC)));
  }
  </code></pre>
  
  <p>I can then configure the path to the raw HTML file to be used and it will be loaded into the View.  The View can then house all of the paths to load jQuery, CSS and other necessary javascript to integrate with the raw HTML and allow me to deploy the HTML files into any directory structure that I want.  The configuration XML file allows me to find XML elements and use those values for any HTML that I am looking for, like a welcome and thank you page.  The helper object will open the XML and find the configuration based on the parameters passed to the View.  </p>
  
  <pre><code>&lt;ContentLandingItem entrycode="1" customerID="Cutomer1"&gt;
    &lt;ContentLandingPageSRC&gt;~/Customers/Customer1/Customer1Landing.htm&lt;/ContentLandingPageSRC&gt;
    &lt;ContentThankyouSRC&gt;~/Content/Default/GenericThankyou.htm&lt;/ContentThankyouSRC&gt;
  &lt;/ContentLandingItem&gt;
  &lt;ContentLandingItem entrycode="2" customerID="Cutomer2"&gt;
    &lt;ContentLandingPageSRC&gt;~/Customers/Customer2/Customer2Landing.htm&lt;/ContentLandingPageSRC&gt;
    &lt;ContentThankyouSRC&gt;~/Customers/Customer2/Customer2Thankyou.htm&lt;/ContentThankyouSRC&gt;
  &lt;/ContentLandingItem&gt;
  </code></pre>
  
  <p>The view still performs its duties and works independently on it own letting the raw HTML decorate the View.  The model is still intact and can be used as I wish.  The FormCollection is there in case a form submit posts the values to the view and provides some things that I omitted from this question as it did not pertain to this subject.</p>
  
  <p>I don't want to answer my own question and I found the pieces that helped me on another site, so I am putting what I did here in case anyone needs this functionality.</p>