I want to inject a custom ViewEngine into my MVC website. This is what I do:
private static IKernel CreateKernel()
{
kernel.Bind<IViewEngine>().ToProvider(new RazorViewEngineProvider()).InRequestScope();
}
This is my provider:
public class RazorViewEngineProvider : Provider<RazorViewEngine>
{
protected override RazorViewEngine CreateInstance(IContext context)
{
return new RazorViewEngine();
}
}
Problem is: My provider is only called once when I go to the website for the first time. The next time my provider is somehow still in cache. And that's not what I want.
I want the provider to execute on every request. I thought I could do that with .InRequestScope(), but that doesn't make any difference. Does anyone know what's going on?