title: Convert MVC View to Html string
body: <p>I am working in MVC and I want to convert the view to HTML which includes SVG charts(high chart). I have used following code for the same.</p>
  
  <pre><code>static string RenderViewToString(ControllerContext context,
                                   string viewPath,
                                   object model = null,
                                   bool partial = false)
  {
      // first find the ViewEngine for this view
      ViewEngineResult viewEngineResult = null;
      if (partial)
          viewEngineResult = ViewEngines.Engines.FindPartialView( context, viewPath);
      else
          viewEngineResult = ViewEngines.Engines.FindView(context, viewPath, null);
  
      if (viewEngineResult == null)
          throw new FileNotFoundException("View cannot be found.");
  
      // get the view and attach the model to view data
      var view = viewEngineResult.View;
      context.Controller.ViewData.Model = model;
  
      string result = null;
  
      using (var sw = new StringWriter())
      {
          var ctx = new ViewContext(context, view,
                                    context.Controller.ViewData,
                                    context.Controller.TempData,
                                    sw);
          view.Render(ctx, sw);
          result = sw.ToString();
      }
  
      return result;
  }
  </code></pre>
  
  <p>From the above code we can convert static view to html but not dynamic. My view has Jquery client scripts which are written in document.ready() to draw default chart and associated tables. Please help me to render the view page after chart and associated data manipulations.</p>