Search code examples
nancy

Custom View folder in NancyFx


I want to use different folders other than Views with NancyFx. I've created a custom bootstrapper and it looks like:

using Nancy;

namespace MyBootstrapperTest
{
    public class CustomBootstrapper : DefaultNancyBootstrapper
    {
        protected override void ConfigureConventions(Nancy.Conventions.NancyConventions nancyConventions)
        {
            nancyConventions.ViewLocationConventions.Add((viewName, model, context)) => string.Concat("html/", viewName));
        }
    }
}

But Visual Studio is telling me that the overloaded function, ViewLocationConventions.Add, has invalid arguments. Am I missing something? I'm pretty new to Nancy, using Nancy self-hosting at version 0.21.1.


Solution

  • You're not closing the parenthesis properly. Also it could be convenient to clear conventions first:

    nancyConventions.ViewLocationConventions.Clear();
    nancyConventions.ViewLocationConventions.Add((viewName, model, context) => 
        string.Concat("html/", viewName));