I am trying to use Nancy (using the Self Hosting with Razor views nuget packages) inside of a Topshelf service. I am hosting it on http://localhost:8585/, and it works just fine while I'm in debug mode or call my executable directly. The Nancy module serves up a razor view perfectly.
I then install the application:
myapp.exe install
When I start the service, it seems to be working just fine, and there are no errors. Then, when I go to http://localhost:8585/ in the browser I get a blank response. Any ideas as to why?
Before I start hosting the service with Topshelf, I start up Nancy:
_nancyHost = new NancyHost(_baseUri);
_nancyHost.Start();
After that, the topshelf service is configured and started like this:
using (Container)
{
var host = HostFactory.New(config =>
{
config.EnableDashboard();
config.AfterStartingServices(() => Console.WriteLine("Done starting..."));
config.Service<EventHandlerService>(s =>
{
s.SetServiceName("EventHandlerService");
s.ConstructUsing(c => Container.Get<EventHandlerService>());
s.WhenStarted(n => StartService(n, stopwatch));
s.WhenStopped(n => StopService(n, stopwatch));
});
config.RunAsLocalSystem();
config.SetDescription("A service for processing events.");
config.SetDisplayName("EventHandlerService");
config.SetInstanceName("EventHandlerService");
config.SetServiceName("EventHandlerService");
});
host.Run();
}
I am using ninject, and the StartService and StopService methods are just functions that print the current value of stopwatch.ElapsedMilliseconds.
Here's the configuration of my Nancy module:
Get["/"] = parameters =>
{
var indexViewModel = new IndexViewModel { CurrentDateTime = DateTime.Now, WorkLog = _service.WorkLog };
return View["index", indexViewModel];
};
Get["/js/{file}"] = p =>
{
return Response.AsJs("scripts/" + p.file as String);
};
Get["/style/{file}"] = p =>
{
return Response.AsCss("content/themes/base/" + p.file as String);
};
Get["/img/{file}"] = p =>
{
return Response.AsImage("content/themes/base/images/" + p.file as String);
};
I'm using all of the defaults in Nancy, other than the Self Hosting & Razor parts. Any idea what might be going on?
I also tried netsh http add urlacl url=http://+:8585/ user=\Everyone
and it didn't seem to have any affect on the behavior.