Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

.net

razor

nancy

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.

like image 434
Neil Thompson Avatar asked Nov 04 '22 13:11

Neil Thompson


1 Answers

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
    }
}
like image 127
Steven Robbins Avatar answered Nov 17 '22 12:11

Steven Robbins