Search code examples
.netrazornancy

Nancy with Razor: Views are cached, making development really hard


I'm new to Nancy and Razor (and MVC). If I make a change to a view I have to restart the application somehow (change web.config, restart dev server etc) for the change to take affect.

I think the cache may be Razor's static dictionary? It stores each compiled view? No doubt this is great for production, but how do I turn it off for development? I want to be able to modify a view, save, build and see the change.

Any advise greatly appreciated. Thanks.


Solution

  • This will be fixed for 0.8, but for now you can turn the caching off by adding a line to your bootstrapper's InitializeInternal like this:

    public class CustomBootstrapper : DefaultNancyBootstrapper
    {
        protected override void InitialiseInternal(TinyIoC.TinyIoCContainer container)
        {
            base.InitialiseInternal(container);
    #if DEBUG
            StaticConfiguration.DisableCaches = true;
    #endif
        }
    }