Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy Razor-Views for Self-hosting NancyFx?

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

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

One consequence is that changes to the Views will not be shown/updated until a restart. Even when working in debug-mode, where caching is disabled by default. I know this is just a minor annoyance, but still an annoyance, and it is nice to be able to try (cs)HTML-changes right away. So I was wondering is there a way to fix this, e.g. to prevent having to set the files to Copy if newer?

like image 685
Yahoo Serious Avatar asked Jun 07 '13 10:06

Yahoo Serious


2 Answers

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

like image 160
jrsconfitto Avatar answered Nov 18 '22 06:11

jrsconfitto


You will need to set these values:

#if DEBUG
  StaticConfiguration.Caching.EnableRuntimeViewDiscovery = true
  EnableRuntimeViewUpdates = true
#endif
like image 24
Jon Avatar answered Nov 18 '22 07:11

Jon