我已经跨越了许多障碍,但是我仍然看到 Nancy 呈现的默认 404 iamge。我已经“掌握”了,project.json
所以我可以使用文件中的以下块嵌入我的资产(包括 /assets/views/index.html)project.json
:
"buildOptions": {
"embed": [
"assets/**",
"Content/**",
"fonts/**",
"Scripts/bootstrap.js",
"Scripts/jquery-2.2.2.js",
"Scripts/mustache.js",
"favicon.ico"
//, "Scripts/**" - include this and build fails with errors in *.targets (!)
]
}
这在调试和查询程序集资源时得到确认。都好。
我的引导程序包含:
protected override void ConfigureApplicationContainer(TinyIoCContainer container)
{
DependencyResolver.ConfigureDependencies(container);
ResourceViewLocationProvider
.RootNamespaces
.Add(GetAssembly(), "<name to assembly>"); //embedded resource directory location
}
然而在我的 IndexModule 中:
public class IndexModule : NancyModule
{
public IndexModule()
{
Get("/", args => Response.AsFile("assets/views/index.html", "text/html"));
}
}
这什么都没有......我会错过任何东西吗?它与 .Net Framework 配合得很好