I want to serve my static files from a parent directory so I can modify them for easy development while the application is still running. I have tried to add a static content convention in my Bootstrapper like so:
this.Conventions.StaticContentsConventions.Add(
StaticContentConventionBuilder.AddDirectory("content", @"../../content")
);
base.ConfigureConventions(nancyConventions);
But it is still not able to find those static files. Is it not possible to serve from a parent folder?
Not with the StaticContentConventionBuilder; we explicitly don’t allow this for security reasons. We make sure whatever file that’s requested by the user always falls within the scope of the web root, otherwise people could potentially use some path manipulation to retrieve files you didn’t want them to.
If you really have to do this (although your reasoning makes little sense when you can edit the files in the web root just as easily as anywhere else), then you will have to write the convention from scratch yourself – it’s a Func.