title: ASP.NET MVC Saving a view as HTML file
body: <p>I have a pretty basic page that has a few images via relative paths that I need to save to a .html file.</p>
  
  <p>I have used this in the past but had problems with the images.</p>
  
  <pre><code>public static class ActionResultExtensions
  {
      public static string Capture(this ActionResult result, ControllerContext controllerContext)
      {
          using (var capture = new ResponseCapture(controllerContext.RequestContext.HttpContext.Response))
          {
              result.ExecuteResult(controllerContext);
              return capture.ToString();
          }
      }
  }
  
  public class ResponseCapture : IDisposable
  {
      private readonly HttpResponseBase _response;
      private readonly TextWriter _originalWriter;
      private StringWriter _localWriter;
  
      public ResponseCapture(HttpResponseBase response)
      {
          _response = response;
          _originalWriter = response.Output;
          _localWriter = new StringWriter();
          response.Output = _localWriter;
      }
  
      public override string ToString()
      {
          _localWriter.Flush();
          return _localWriter.ToString();
      }
  
      public void Dispose()
      {
          if (_localWriter == null) return;
  
          _localWriter.Dispose();
          _localWriter = null;
          _response.Output = _originalWriter;
      }
  }
  </code></pre>
  
  <p>I'd like to know how to get the result WITH all of the CSS and images downloaded along with the HTML in a nice little package.</p>