0

I want to write an self-hosted web application usign OWIN / Katana and Nancy. I understand the concept of OWIN and have figured out many things about Katana and Nancy. But I don't understand how can I self-host my application without a console.
Like every tutorial / code examples / documentations I can find are like the following example

using (WebApp.Start<Startup>(url))
{
    Console.ReadLine();
}

But I don't want to run a console application later. I want to run a "hidden" app - probably a windows service.

So I hope you already got what my question is. But I'll try to explain it again in other words: How do I prevent that my application stops before I want to stop it?

Imagine I would do this:

private static void Main(string[] args)
{
    var url = "http://+:8080";
    var app = WebApp.Start<OwinStartup>(url);
}    

The application would - obviously - immediately end.

Okay actually the Nancy part of my question isn't that important. I've just added it to explain my complete situation.

  • Using some kind of signal, like a `WaitHandle` (implemented through for example a `ManualResetEvent`), which blocks until you flag it. See duplicate. – CodeCaster Jan 30 '15 at 14:04
  • @CodeCaster I really don't see the duplicate here. I don't want to run a console application and can't bind to ctrl+c. Or am I getting something wrong here? – HowLongCanMyUsernameBeHere1234 Jan 30 '15 at 14:08
  • I know, but your code shows otherwise. If you create a Windows Service, all you have to do is start your Owin host and return from `OnStart()`, no need to keep waiting there as `ServiceBase.Run()` will block. So stop imagining and start implementing, and you'll see the question you're asking is moot. – CodeCaster Jan 30 '15 at 14:10
  • Look into creating a windows service. OWIN/Katana is no different, simply override `OnStart` and `OnStop` – Yuval Itzchakov Jan 30 '15 at 14:12

0 Answers0