Nancy 在错误的项目中查找视图

Nancy looks for views in wrong project

编辑

我刚刚从 GitHub 下载了教程项目的源代码。当我构建和 运行 项目时,我看到 Website/Modules/ 文件夹被复制到 Service 项目的 bin/Debug 文件夹中。但是当我构建我的 Service 项目时,这不会发生。

可能是什么原因?


我正在学习 this link 中的教程。

我已经完成了添加 index.html 的部分,加载网页时应该会显示 Nancy is working!

我不得不将 ViewLocationConventions 更改为

$"../../../Service.Website/Website/Modules/{context.ModuleName}/views/{viewName}"

只有这样,Nancy 1.x 版本才能正常工作。为什么在我使用

时它不起作用
$"Website/Modules/{context.ModuleName}/views/{viewName}"

喜欢教程吗?

当我使用 Nancy 2.x 时,它根本找不到视图文件。无论我将 ViewLocationConventions 设置为什么。

也就是说,它仍然在 Service 项目中寻找 Website/Modules/Root/view/index.html 文件。

除了将视图文件本身移动到 Service 项目之外,还有其他解决方法吗?


教程的快速背景:

该解决方案有 2 个项目 ServiceService.Website,如下所示。

  1. Service 是一个托管服务器的 Topshelf 服务,该服务器 运行 是 Web 项目
  2. Service.Website 是一个使用 Owin 和 Nancy 的网络项目

感谢@hellyale 的 ,我不得不将 index.html 文件的 Copy to Output Directory 设置为 Copy always

然后将文件复制到 bin/Debug 文件夹,Nancy 现在可以找到该视图。