Xpleria
Xpleria

Reputation: 5853

Nancy looks for views in wrong project

Edit

I just downloaded the source code of the tutorial project from GitHub. When I build and run the project, I see that the Website/Modules/ folder is copied into the bin/Debug folder of the Service project. But this does not happen when I build my Service project.

What could be the reason?


I am following the tutorial in this link.

I have completed the part until the index.html is added and should show Nancy is working! when the webpage is loaded.

I had to change the ViewLocationConventions to

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

Only then everything works fine with Nancy 1.x version. Why doesn't it work when I use

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

like in the tutorial?

And when I use Nancy 2.x, it cannot find the view file at all. No matter what I set ViewLocationConventions to.

i.e., it still looks for the Website/Modules/Root/view/index.html file in the Service project.

Any other workaround, other than moving the view files itself to the Service project?


Quick background of the tutorial:

The solution has 2 projects Service and Service.Website as shown below.

  1. Service is a Topshelf service that hosts a server that runs the web project
  2. Service.Website is a web project using Owin and Nancy

enter image description here

Upvotes: 1

Views: 206

Answers (1)

Xpleria
Xpleria

Reputation: 5853

Thanks to @hellyale's comment, I had to set the Copy to Output Directory of the index.html file to Copy always.

This then copies the file to the bin/Debug folder and Nancy is now able to find the view.

Upvotes: 1

Related Questions