Nancyfx - serving static files from parent folder

I want to serve my static files from the parent directory, so I can modify them for easy development while the application is still running. I tried to add a static content convention to my Bootstrapper:

this.Conventions.StaticContentsConventions.Add(
  StaticContentConventionBuilder.AddDirectory("content", @"../../content")
);
base.ConfigureConventions(nancyConventions);

      

But it cannot find these static files. Can't this be done from the parent folder?

+3


source to share


2 answers


Not with StaticContentConventionBuilder; we clearly do not allow this for security reasons. We ensure that any file requested by the user always falls within the scope of the web root, otherwise people could potentially use some path manipulation to get files you didn't want them in.



If you really need to do this (although your reasoning doesn't make sense when you can edit files in the root directory as easily as anywhere else), you'll have to write the convention from scratch yourself - that's Func.

+4


source


You can implement IRootPathProvider

in debug builds and return the path you want.



0


source







All Articles