title: MVC : Get HTML string From Controller/Action, from a call from other controller
body: <p>I have a controller : TestController.cs</p>
  
  <pre><code>public ActionResult Test()
  {
      return View();        
  }
  
  public string TestHtml()
  {        
      //Get Result of Test as HTML string
      string HTMLString = "";
  
      ActionResult AR = Test();
      //Convert AR to HTML string
  
      HTMLString = ConvertActionResultToHtml(AR);
  
      //do something with HTMLString
  
      return HTMLString;
  }
  </code></pre>
  
  <p>The Test() function has a view to it which returns a piece of HTML.</p>
  
  <p>When i call the TestHtml() function i would like to get the same HTML but as a string, so i need the function "ConvertActionResultToHtml". Is there something like that. </p>
  
  <p>I know there are MVC2mail components which do the same, render a View as Email.</p>
  
  <p>When it can be done i would like to have a generic function to achive this. like :</p>
  
  <pre><code>public string GetHTMLFromControllerAction(string Controller, string Action) {
      //This function returns the result of a controller action as HTML string
      return ""; //
  } 
  </code></pre>
  
  <p>The code above i would like to call from another controller.</p>
  
  <p>I tried the following code : 
  <a href="https://stackoverflow.com/questions/18335402/how-to-get-view-html-and-return-to-client-side">How to get view html and return to client side</a>, but can't get it to work calling it from an another controller function.</p>
  
  <p>Hope someone can help, or can give me any tips on an other sollution for this.</p>