南希视图内部服务器错误

时间:2013-04-11 20:00:19

标签: c# nancy self-hosting

我在我的控制台应用程序中托管Nancy,当我尝试调用视图(例如“Login.html”)时,该页面给出了错误500.这是代码:

public sealed class LoginModule : NancyModule
{
    private readonly DatabaseList _db = Singleton.DB;
    public LoginModule()
    {
        Get["/"] = x => View["Login.html"];
    }
}

我实现了自己的bootstrap,因为我需要会话:

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
    • Nancy.cs
  • 查看/
    • 的login.html

我尝试删除所有组合删除CurrentDirectory,ViewLocationConventions,每种类型的路径,如/ Views /,.. / Views /等,但仍然没有。我还尝试将Views路径放在WebControllers中,甚至只放入Index.html文件中。总之,我还试图将Views重命名为Login,无所事事。

1 个答案:

答案 0 :(得分:3)

确保您的视图文件设置为复制到输出文件夹,您应该好好去