title: Render View as String
body: <p>Am trying to render a view as a string to be used as an email template. Am currently trying to implement this example:
  <a href="https://weblog.west-wind.com/posts/2012/May/30/Rendering-ASPNET-MVC-Views-to-String" rel="nofollow">https://weblog.west-wind.com/posts/2012/May/30/Rendering-ASPNET-MVC-Views-to-String</a></p>
  
  <p>However am having difficulty with this section of code:</p>
  
  <pre><code>public ViewRenderer(ControllerContext controllerContext = null)
  {
      // Create a known controller from HttpContext if no context is passed
      if (controllerContext == null)
      {
          if (HttpContext.Current != null)
              controllerContext = CreateController&lt;ErrorController&gt;().ControllerContext;
          else
              throw new InvalidOperationException(
                  "ViewRenderer must run in the context of an ASP.NET " +
                  "Application and requires HttpContext.Current to be present.");
      }
      Context = controllerContext;
  }
  </code></pre>
  
  <p>Visual Studio is giving me the following error:</p>
  
  <blockquote>
    <p>"The type or namespace name 'ErrorController' could not be found (are you missing a using directive or an assembly reference?)"</p>
  </blockquote>
  
  <p>Am probably missing something obvious but can't see what it is. Any ideas?</p>