gpt4 book ai didi

c# - Nancy 查看内部服务器错误

转载 作者:行者123 更新时间:2023-11-30 22:18:40 24 4
gpt4 key购买 nike

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

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

我实现了自己的 Bootstrap ,因为我需要 session :

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));
}
}

这是我项目的树:各种路径;

  • 网络 Controller /
    • 登录模块.cs
    • 南希.cs
  • 浏览量/
    • 登录.html

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

最佳答案

确保您的 View 文件已设置为复制到输出文件夹,您应该可以开始了

关于c# - Nancy 查看内部服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15957791/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com