I'm serving static content in a self-hosted Nancy and have overridden the root path, and also added a static content convention to redirect / to Content in my custom bootstrapper like so:
conventions.StaticContentsConventions.Add(StaticContentConventionBuilder.AddDirectory("/", "Content"));
This works fine when requesting a URL like http://localhost/index.html but I would like http://localhost to redirect to index.html. This doesn't seem to work by default though. What am I doing wrong?
I ended up solving this with a simple module like so:
public class IndexModule : NancyModule
{
public IndexModule()
{
Get["/"] = _ => Response.AsFile(Settings.Instance.GetFullContentPath("index.html"));
}
}
Settings.Instance.GetFullContentPath
is my own method which returns a full path on disk to the specified file.