开发者

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

开发者 https://www.devze.com 2023-04-08 20:52 出处:网络
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'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 gr开发者_开发技巧eat 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.


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
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消