问题
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?
回答1:
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
回答2:
You can (re)create/(re)start the server when you like during the lifetime of the application.
来源:https://stackoverflow.com/questions/30923217/asp-net-self-hosted-application