I have a console app which i want to use Nancy to host a web service. here is my 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();
}
}
}
and here is my MainModule.cs file
namespace NancyConsole
{
using Nancy;
internal class MainModule : NancyModule
{
public MainModule()
{
Get["/"] = x => View["Views/index.html"];
}
}
}
When i run the project this is the error i get on the browser
I dont know where i am going wrong? Your help will be highly appreciated!
Make the module public. The default loading strategy uses reflection to find public module classes.
public class MainModule : NancyModule
From the documentation:
It is important that you declare your module public, otherwise NancyFx is not able to discover your module.