title: How to render action as HTML and invoke ActionFilters from another controller action
body: <p>From within a controller action I need to call another action and have any applicable <code>ActionFilter</code> on the called action fired as well. I need to do this because I am passing the resultant HTML to a PDF generator.</p>
  
  <p>This is what I currently have, but it doesn't call <code>SomeActionFilter.OnActionExecuting()</code></p>
  
  <pre><code>[SomeActionFilter]
  public class FooController : Controller
  {
       public ActionResult ActionOne()
       {
            return View();
       }
  
       public ActionResult ActionTwo()
       {
           // This is how I'm rendering the view to HTML at the moment
           var controllerDescriptor = new ReflectedControllerDescriptor(ControllerContext.Controller.GetType());
           var actionDescriptor = controllerDescriptor.FindAction(ControllerContext, "ActionOne");
           var result = actionDescriptor.Execute(ControllerContext, new Dictionary&lt;string, object&gt;()) as ViewResult;
  
           ViewEngineResult viewEngineResult = ViewEngines.Engines.FindView(controllerContext, viewName, null);
  
           var builder = new StringBuilder();
           using (var writer = new StringWriter(builder))
           {
               var context = new ViewContext(controllerContext, viewEngineResult.View, result.ViewData, result.TempData, writer);
               viewEngineResult.View.Render(context, writer);
           }
  
           string actionOneAsHtml = builder.ToString();
           // From here on I'm just using the rendered HTML to generate the PDF ... 
  
           byte[] pdf = _acrobatExportService.ExportFromUrl(new AcrobatExportModel
           {
               Html = actionOneAsHtml 
           });
  
           return File(pdf, "application/pdf", "export.pdf");
       }
  }
  </code></pre>
  
  <p>I know I <em>could</em> call the action using HTTP, but that seems redundant.</p>