0

How to control ASP.Net 5 application from console application? All examples of self-hosted application I've found assume that the lifetime of the webserver matches the lifetime of application. Is it possible to have assembly of ASP.Net 5 application with Startup.cs file and main assembly (console app) which allows to start and stop web application using this Startup class when I need? For example, Node.js allows to initiate new server at any place in code, like this

http.createServer(function (req, res) { /* processing request }).listen(80, '127.0.0.1');

Is it possible to implement anything like this in ASP.Net 5?

Random
  • 3,807
  • 2
  • 30
  • 49

2 Answers2

0

You can (re)create/(re)start the server when you like during the lifetime of the application.

Andrei Tătar
  • 7,872
  • 19
  • 37
  • As far as I understand this solution will work for previous versions of ASP.Net but not for the ASP.Net 5. – Random Jun 18 '15 at 19:22
0

When you use the hosting API in your Program.Main, you can achieve the same thing.

UPDATE: This is the RC1 API:

https://github.com/aspnet/Hosting/blob/1.0.0-rc1/src/Microsoft.AspNet.Hosting/Program.cs

post RC1 is very different

davidfowl
  • 37,120
  • 7
  • 93
  • 103