ASP.Net self-hosted application

二次信任 提交于 2019-12-25 05:32:37

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!