ASP.Net自托管应用程序 [英] ASP.Net self-hosted application

查看:61
本文介绍了ASP.Net自托管应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从控制台应用程序控制ASP.Net 5应用程序?我发现的所有自托管应用程序示例均假定Web服务器的生存期与应用程序的生存期匹配.是否可以将带有 Startup.cs 文件和主程序集(控制台应用程序)的ASP.Net 5应用程序进行组装,从而允许使用此 Startup 类启动和停止Web应用程序我什么时候需要?例如,Node.js允许在代码中的任何位置启动新服务器,例如

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');

是否可以在ASP.Net 5中实现类似的功能?

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

推荐答案

在Program.Main中使用托管API时,您可以实现相同的目的.

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

更新:这是RC1 API:

UPDATE: This is the RC1 API:

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

RC1的发布与众不同

post RC1 is very different

这篇关于ASP.Net自托管应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆