Getting Started 시작하기¶
- Install .NET Core
- .NET Core 설치해주세요.
- Create a new .NET Core project:
- 신규 .NET Core 프로젝트를 생성해주세요.
mkdir aspnetcoreapp cd aspnetcoreapp dotnet new
- Update the project.json file to add the Kestrel HTTP server package as a dependency:
- 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" } } }
- Restore the packages:
- 종속된 패키지들을 다시 불러와주세요.
dotnet restore
- Add a Startup.cs file that defines the request handling logic:
- 요청을 처리할 로직을 정의하는 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!"); }); } } }
- Update the code in Program.cs to setup and start the Web host:
- 웹 호스트를 설정하고 시작하는 코드를 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(); } } }
- Run the app (the
dotnet run
command will build the app when it’s out of date):
- 앱을 실행해주세요. (
dotnet run
명령을 실행할 때 소스에 변경 사항이 있다면, 앱을 다시 빌드할 것입니다.)
dotnet run
- Browse to http://localhost:5000:
- http://localhost:5000 을 브라우저에서 열어주세요.