title: Razor engine not finding views
body: <h2>Issue</h2>
  
  <p>I currently have a .NET Core library that I am using to render Razor pages as HTML emails. I am following <a href="https://scottsauber.com/2018/07/07/walkthrough-creating-an-html-email-template-with-razor-and-razor-class-libraries-and-rendering-it-from-a-net-standard-class-library/" rel="nofollow noreferrer">this tutorial</a>. There are no errors during compile-time but at runtime I am getting the following error:</p>
  
  <blockquote>
    <p>'Unable to find view '/Views/Emails/NewOrder/NewOrder.cshtml'. The
    following locations were searched:
    /Views/Emails/NewOrder/NewOrder.cshtml'</p>
  </blockquote>
  
  <p>I have set the build action of <code>NewOrder.cshtml</code> to <code>Content</code> and I have set the copy to output directory to <code>Copy Always</code>. I am unsure to why this is unable to find the view as I can see in the <code>bin\Debug\netcoreapp2.2\Views</code> folder that the emails are being copied to the output directory. </p>
  
  <hr>
  
  <h2>Code</h2>
  
  <p>I am searching for the view with the following code:</p>
  
  <pre><code>private IView FindView(ActionContext actionContext, string viewName)
  {
      var getViewResult = _viewEngine.GetView(executingFilePath: null, viewPath: viewName, isMainPage: true);
      if (getViewResult.Success)
      {
          return getViewResult.View;
      }
  
      var findViewResult = _viewEngine.FindView(actionContext, viewName, isMainPage: true);
      if (findViewResult.Success)
      {
          return findViewResult.View;
      }
  
      var searchedLocations = getViewResult.SearchedLocations.Concat(findViewResult.SearchedLocations);
      var errorMessage = string.Join(
          Environment.NewLine,
          new[] {$"Unable to find view '{viewName}'. The following locations were searched:"}.Concat(
              searchedLocations));
  
      throw new InvalidOperationException(errorMessage);
  }
  </code></pre>