Copy Razor-Views for self-hosted NancyFx?

I started with a simple MVC site using NancyFx with Razor-view ( .cshtml ) and Nancy.Hosting.Aspnet using IIS Express. Now I have adapted the project to self-service using Nancy.Hosting.Self (and TopShelf).

However, to provide the views, it seems to me that I need to change their properties from None and Do not copy to Content and Copy if newer , so they are copied to .\bin\Debug\ .

One consequence is that changes to Views will not be displayed / updated until restarted. Even when working in debug-mode, where caching is disabled by default . I know that this is just a minor annoyance, but still annoying, and it's nice to immediately try (cs) the HTML changes. So I was wondering if there is a way to fix this, for example. to prevent installing files on Copy if newer ?

+6
source share
2 answers

You can provide a custom root path that will look directly in the views folder in your project.

+6
source

You will need to set the following values:

 #if DEBUG StaticConfiguration.Caching.EnableRuntimeViewDiscovery = true EnableRuntimeViewUpdates = true #endif 
+3
source

Source: https://habr.com/ru/post/946762/


All Articles