Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Nancy self-hosting example
// a simple module to be hosted in the console app
public class MainModule : NancyModule
{
public MainModule()
{
Get["/"] = x => { return "Hello World"; };
}
}
static void Main(string[] args)
{
// initialize an instance of NancyHost (found in the Nancy.Hosting.Self package)
var host = new NancyHost(new Uri("http://localhost:12345"));
host.Start(); // start hosting
Console.ReadKey();
host.Stop(); // stop hosting
}
@zgrkpnr

This comment has been minimized.

Copy link

commented Oct 26, 2017

Where do you use MainModule ? Why did you define it if you don't use it.

@sam453

This comment has been minimized.

Copy link

commented Nov 14, 2017

Nancy automatically discovers all modules so we don’t have to register them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.