3

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?

0

2 Answers 2

2

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.

5
  • Will dnx run as a Windows background service? Feb 11, 2016 at 21:19
  • No, it will run as a Windows process.
    – hcp
    Feb 12, 2016 at 2:07
  • So, will this process terminate once the console window, from which it was launched is closed, or will it continue to run in the background? Feb 12, 2016 at 2:09
  • You can specify new task in Windows Sheduler, for example. Then it will be runner in background mode. Or use third-party tools for running the process as a service.
    – hcp
    Feb 12, 2016 at 2:15
  • This example uses owin and hosted in windows service - blog.uship.com/shippingcode/… Aug 23, 2016 at 12:02
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.