Static conventions are initialized BEFORE StaticContentConfiguration initialization. If custom StaticContentConfiguration changes root directory, path to files, matched by static conventions, are related to directory, that WAS root before StaticContentConfiguration was initialized.
Steps to Reproduce
Make a custom static conventions either way, via bootstrapper or implementing IConvention interface:
// this will be executed before CustomStaticConfiguration
conv.StaticContentsConventions.AddFile("/test.css", @"content/static/test.min.css");
Make a custom static configuration:
public class CustomStaticConfiguration : DefaultStaticContentConfigurationProvider
{
private const string RootPath = @"../../../PublicOffice";
public CustomStaticConfiguration()
: base(new RootPathProvider())
{
}
private class RootPathProvider : IRootPathProvider
{
// this will be executed after static conventions initialization
public string GetRootPath() => Path.Combine(Directory.GetCurrentDirectory(),
RootPath);
}
}
Make a module, returning same static content:
public sealed class StaticExampleModule : NancyModule
{
public StaticExampleModule()
{
this.Get("/example", _ => new GenericFileResponse(@"content/static/test.min.css",
this.Context));
}
}
When you query http://localhost/test.css (static conventions) and http://localhost/example (module), different files are accessed by nancy:
But they both must be same - /example correspond to valid path. /test.css lead to 404.
Description
Static conventions are initialized BEFORE
StaticContentConfiguration
initialization. If customStaticContentConfiguration
changes root directory, path to files, matched by static conventions, are related to directory, that WAS root beforeStaticContentConfiguration
was initialized.Steps to Reproduce
Make a custom static conventions either way, via bootstrapper or implementing
IConvention
interface:Make a custom static configuration:
Make a module, returning same static content:
When you query
http://localhost/test.css
(static conventions) andhttp://localhost/example
(module), different files are accessed by nancy:But they both must be same -
/example
correspond to valid path./test.css
lead to 404.System Configuration