コンソール アプリケーションで Nancy をホストしています。ビュー (たとえば、「Login.html」) を呼び出そうとすると、ページでエラー 500 が表示されます。これがコードです。
public sealed class LoginModule : NancyModule
{
private readonly DatabaseList _db = Singleton.DB;
public LoginModule()
{
Get["/"] = x => View["Login.html"];
}
}
セッションが必要なため、独自のブートストラップを実装しました。
public class Bootstrapper : DefaultNancyBootstrapper
{
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
var directoryInfo = new FileInfo(Assembly.GetExecutingAssembly().Location).Directory;
if (directoryInfo != null)
Environment.CurrentDirectory = directoryInfo.FullName;
CookieBasedSessions.Enable(pipelines);
Conventions.ViewLocationConventions.Add((viewName, model, viewLocationContext) => String.Concat("Views/", viewName));
}
}
これは私のプロジェクトのツリーです。さまざまなパス。
- WebControllers/
- LoginModule.cs
- ナンシー.cs
- ビュー/
- ログイン.html
CurrentDirectory、ViewLocationConventions、/Views/、../Views/ などのすべてのタイプのパスを削除するすべての組み合わせを削除しようとしましたが、まだ何もありません。また、Views パスを WebControllers 内に配置しようとしましたが、Index.html ファイルだけを配置しようとしましたが、まだ何もありません。結論として、ビューの名前をログインに変更しようとしましたが、何もしませんでした。