[英]Is it possible to self-host an ASP.NET Core Application without IIS?
I have a full-working ASP.NET MVC application (.NET Core, ASP.NET Core) which runs fine in Visual Studio (which uses IISExpress).我有一个完整的 ASP.NET MVC 应用程序(.NET Core、ASP.NET Core),它在 Visual Studio(使用 IISExpress)中运行良好。
I would now like to have a console application which takes the ASP.NET Core application and hosts it (self hosting).我现在想要一个控制台应用程序,它采用 ASP.NET Core 应用程序并托管它(自托管)。
Is it possible to self-host an ASP.NET Core Application without IIS?是否可以在没有 IIS 的情况下自托管 ASP.NET Core 应用程序?
Yes.是的。 In fact, all ASP.NET Core applications are self-hosted.事实上,所有 ASP.NET Core 应用程序都是自托管的。 Even in production, IIS/Nginx/Apache are a reverse proxy for the self-hosted application.即使在生产中,IIS/Nginx/Apache 也是自托管应用程序的反向代理。
In a reasonably standard Program.cs class, you can see the self-hosting.在相当标准的 Program.cs 类中,您可以看到自托管。 The IISIntegration
is optional - it's only necessary if you want to integrate with IIS. IISIntegration
是可选的 - 只有当您想与 IIS 集成时才需要它。
public class Program
{
public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.AddCommandLine(args)
.AddEnvironmentVariables(prefix: "ASPNETCORE_")
.Build();
var host = new WebHostBuilder()
.UseConfiguration(config)
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
}
Yes,ASP.NET Core supports the Open Web Interface for .NET ( OWIN ),your have two options to host your Asp.net core web application:是的,ASP.NET Core 支持 .NET 的开放式 Web 界面 ( OWIN ),您有两种选择来托管您的 Asp.net Core Web 应用程序:
IIS信息系统
Self-Host自托管
But,self-hosting web application can't restart automatically on system boot and restart or in the event of a failure.但是,自托管 Web 应用程序无法在系统启动和重启或出现故障时自动重启。
YES是的
ASP.NET 5 is completely decoupled from the web server environment that hosts the application. ASP.NET 5 与承载应用程序的 Web 服务器环境完全分离。 ASP.NET 5 supports hosting in IIS and IIS Express, and self-hosting scenarios using the Kestrel and WebListener HTTP servers. ASP.NET 5 支持在 IIS 和 IIS Express 中托管,以及使用 Kestrel 和 WebListener HTTP 服务器的自托管方案。 Additionally, developers and third party software vendors can create custom servers to host their ASP.NET 5 apps.此外,开发人员和第三方软件供应商可以创建自定义服务器来托管他们的 ASP.NET 5 应用程序。
more info: ASP.NET documentation - Servers更多信息: ASP.NET 文档 - 服务器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.