I'm having trouble serving up static content such as JavaScript in Nancy.
For example using the self hosting sample I have added a test.js to the Views folder and added a
<script type="text/javascript" src="test.js"></script>
tag to the staticview.html page. If I view this page in the browser the JavaScript is executed correctly.
However when I run the sample the JavaScript is not executed. If I view the page in FireBug I see that I'm getting a 404 error for test.js.
I've tried adding
Get["{file}"] = p =>
{
string path = string.Format("Views/{0}", p.file);
return Response.AsJs(path);
};
and when I set a break point and execute Response.AsJs(path) in the immediate window I get a StatusCode of NotFound
I've also tried adding a StaticContentConvention such as
protected override void ConfigureConventions(NancyConventions conventions)
{
base.ConfigureConventions(conventions);
conventions.StaticContentsConventions.Add(
StaticContentConventionBuilder.AddDirectory("/", "Views"));
conventions.StaticContentsConventions.Add(
StaticContentConventionBuilder.AddDirectory("Views", "Views"));
}
What am I doing wrong?