ind*_*ago 2 c# self-hosting nancy
我有一个控制台应用程序,我想使用Nancy托管Web服务。这是我的Program.cs
namespace NancyConsole
{
using Nancy.Hosting.Self;
using System;
internal class Program
{
private static void Main(string[] args)
{
string url = "http://localhost:1234";
var host = new NancyHost(new Uri(url));
host.Start();
Console.WriteLine("Server started, now listening on " + url);
Console.WriteLine("Press any key to stop the server...");
Console.ReadKey();
host.Stop();
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的MainModule.cs文件
namespace NancyConsole
{
using Nancy;
internal class MainModule : NancyModule
{
public MainModule()
{
Get["/"] = x => View["Views/index.html"];
}
}
}
Run Code Online (Sandbox Code Playgroud)
我不知道我要去哪里错了?非常感谢您的帮助!
将模块公开。默认的加载策略使用反射来查找公共模块类。
public class MainModule : NancyModule
Run Code Online (Sandbox Code Playgroud)
从文档中:
将模块声明为公共很重要,否则NancyFx无法发现您的模块。
| 归档时间: |
|
| 查看次数: |
832 次 |
| 最近记录: |