Getting Started

  1. Install .NET Core
  2. Create a new .NET Core project:
mkdir aspnetcoreapp
cd aspnetcoreapp
dotnet new
  1. Update the project.json file to add the Kestrel HTTP server package as a dependency:
{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },
  "dependencies": {
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0"
    },
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0"
  },
  "frameworks": {
    "netcoreapp1.0": { }
  }
}
  1. Restore the packages:
dotnet restore
  1. Add a Startup.cs file that defines the request handling logic:
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;

namespace aspnetcoreapp
{
    public class Startup
    {
        public void Configure(IApplicationBuilder app)
        {
            app.Run(context =>
            {
                return context.Response.WriteAsync("Hello from ASP.NET Core!");
            });
        }
    }
}
  1. Update the code in Program.cs to setup and start the Web host:
using System;
using Microsoft.AspNetCore.Hosting;

namespace aspnetcoreapp
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var host = new WebHostBuilder()
                .UseKestrel()
                .UseStartup<Startup>()
                .Build();

            host.Run();
        }
    }
}
  1. Run the app (the dotnet run command will build the app when it’s out of date):
dotnet run
  1. Browse to http://localhost:5000:
_images/running-output.png