I am trying to use Nancy (using Self Hosting with Razor views nuget packages) inside a Topshelf service. I host it on http: // localhost: 8585 / and it works great when I'm in debug mode or call my executable directly. Nancy's module is great for a razor.
Then I install the application:
myapp.exe install
When I start the service, it works fine and there are no errors. Then, when I go to http: // localhost: 8585 / in the browser, I get an empty response. Any ideas as to why?
Before I start hosting the service using Topshelf, I start Nancy:
_nancyHost = new NancyHost(_baseUri);
_nancyHost.Start();
After that, the topshelf service is configured and started as follows:
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();
}
ninject, StartService StopService - , .ElapsedMilliseconds.
:
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);
};
Nancy, Self Hosting Razor. , ?
netsh http add urlacl url=http://+:8585/ user=\Everyone, , , .