Reputation: 15564
Just started learning ASP.NET 5 / MVC 6 I'm curious about self-hosting such an app outside of IIS - as a Windows service. Should I be using TopShelf for that, like it was the case with OWIN/Katana apps, or does ASP.NET 5 provide some built-in self-hosting (as a service) options via a NuGet package?
Upvotes: 3
Views: 4383
Reputation: 11741
All ASP.NET Core applications are self-hosted.
Yes you read it right!
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();
}
}
Have a look here for more details.
Upvotes: 1
Reputation: 3439
You can use the Kestrel library for self-hosting.
Add dependency to the library in the project.json
file:
"dependencies": {
"EntityFramework.Commands": "7.0.0-rc1-final",
// Dependencies deleted for brevity.
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final"
}
Then scecify this command for Kestrel:
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
}
You can start it by command line from the folder with your MVC project:
dnx web
Please, notify that dnvm
must be runned before.
Upvotes: 2