I have a nancy project which is to serve static content, located in /my/web/root/
. I created a IRootPathProvider
to set the webroot to /my/web/root/
, but when I add the rule StaticContentConventionBuilder.AddDirectory("/", "/")
, "it does not work": the server does not respond.
I can also set the root path to /my/web/
and then set the rule path to /root
, but that is very ugly, and sounds like a source for bugs.
Is there a way to solve this in a neat way?
When I want to serve static content at the root of my web app I configure Nancy the following way.
public class CustomBoostrapper : DefaultNancyBootstrapper
{
protected override void ConfigureConventions(NancyConventions conventions)
{
base.ConfigureConventions(conventions);
conventions.StaticContentsConventions.Add(
StaticContentConventionBuilder.AddDirectory("/", @"_Root")
);
}
}
This will serve static content from a _Root folder in the solution but it will appear as at the root of the application.
e.g.
localhost:3579/text.txt
served from
app-dir\_Root\text.txt