Getting Started 시작하기

  1. Install .NET Core
  1. .NET Core 설치해주세요.
  2. Create a new .NET Core project:
  1. 신규 .NET Core 프로젝트를 생성해주세요.
mkdir aspnetcoreapp
cd aspnetcoreapp
dotnet new
  1. Update the project.json file to add the Kestrel HTTP server package as a dependency:
  1. project.json 파일에서 Kestrel HTTP 서버 패키지를 종속성 (dependencies) 항목에 추가하여 저장해주세요.
{
  "version": "1.0.0-*",
  "buildOptions": {
    "debugType": "portable",
    "emitEntryPoint": true
  },
  "dependencies": {},
  "frameworks": {
    "netcoreapp1.0": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.0.0"
        },
        "Microsoft.AspNetCore.Server.Kestrel": "1.0.0"
      },
      "imports": "dnxcore50"
    }
  }
}
  1. Restore the packages:
  1. 종속된 패키지들을 다시 불러와주세요.
dotnet restore
  1. Add a Startup.cs file that defines the request handling logic:
  1. 요청을 처리할 로직을 정의하는 Startup.cs 파일을 추가해주세요.
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:
  1. 웹 호스트를 설정하고 시작하는 코드를 Program.cs 파일에 추가해주세요.
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):
  1. 앱을 실행해주세요. (dotnet run 명령을 실행할 때 소스에 변경 사항이 있다면, 앱을 다시 빌드할 것입니다.)
dotnet run
  1. Browse to http://localhost:5000:
  1. http://localhost:5000 을 브라우저에서 열어주세요.
_images/running-output.png

Next steps