刚开始学习ASP.NET 5/ MVC 6,我对在IIS之外自托管这样的应用程序感到好奇,因为它是一种Windows服务。我应该为此使用TopShelf,就像OWIN/Katana应用程序那样,还是ASP.NET 5通过NuGet包提供一些内置的自托管(作为服务)选项?
发布于 2016-02-11 06:19:43
您可以使用红隼库进行自我托管。将依赖项添加到project.json文件中的库中:
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
// Dependencies deleted for brevity.
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final"
}然后将此命令剪切为Kestrel:
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
}您可以通过命令行使用MVC项目从文件夹中启动它:
dnx web请通知dnvm必须在此之前运行。
发布于 2016-10-09 10:01:52
所有的ASP.NET核心应用程序都是自我托管的.
是的,你看得对!
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() //// Here IIS integration is optional
.UseStartup()
.Build();
host.Run();
}
}有关更多细节,请查看这里。
https://stackoverflow.com/questions/35330609
复制相似问题