├── tutorials ├── README.md └── build-your-first-blazor-app.md ├── SUMMARY.md ├── README.md ├── get-started.md ├── debugging.md ├── host-and-deploy ├── configure-linker.md ├── hosting-models.md └── README.md ├── layouts.md ├── introduction.md ├── routing.md ├── dependency-injection.md ├── faq.md ├── javascript-interop.md └── components.md /tutorials/README.md: -------------------------------------------------------------------------------- 1 | # 튜토리얼 2 | 3 | `노트: Blazor는 아직 기술 지원이 제공되지 않는 실험용 웹 프레임워크로, 실무 개발에 사용되어서는 안됩니다.` 4 | 5 | [첫 Blazor 앱 만들기](build-your-first-blazor-app.md) 6 | 7 | -------------------------------------------------------------------------------- /SUMMARY.md: -------------------------------------------------------------------------------- 1 | # Table of contents 2 | 3 | * [ASP.NET Blazor 한국어 가이드](README.md) 4 | * [Blazor 시작하기](get-started.md) 5 | * [튜토리얼](tutorials/README.md) 6 | * [첫 Blazor 앱 만들기](tutorials/build-your-first-blazor-app.md) 7 | * [Blazor 소개](introduction.md) 8 | * [컴포넌트](components.md) 9 | * [레이아웃](layouts.md) 10 | * [의존성 주입](dependency-injection.md) 11 | * [라우팅](routing.md) 12 | * [자바스크립트 연동](javascript-interop.md) 13 | * [디버깅](debugging.md) 14 | * [호스팅 및 배포](host-and-deploy/README.md) 15 | * [호스팅 모델](host-and-deploy/hosting-models.md) 16 | * [링커 설정하기](host-and-deploy/configure-linker.md) 17 | * [자주 묻는 질문들](faq.md) 18 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | --- 2 | description: >- 3 | 이 문서는 ASP.NET Blazor Preview Guide 문서를 한국어로 번역한 것으로, Experimental Release에 대한 4 | 문서를 커뮤니티를 위하여 정보 공유를 목적으로 미리 번역한 것입니다. 최신 버전의 내용을 반영하지 못할 수 있으나, 독자 여러분의 기여를 5 | 환영합니다. 6 | --- 7 | 8 | # ASP.NET Blazor 한국어 가이드 9 | 10 | `노트: Blazor는 아직 기술 지원이 제공되지 않는 실험용 웹 프레임워크로, 실무 개발에 사용되어서는 안됩니다.` 11 | 12 | 이 문서는 ASP.NET Blazor Preview Guide 문서 \([https://blazor.net/docs/index.html](https://blazor.net/docs/index.html)\) 를 한국어로 번역한 것으로, Experimental Release에 대한 문서를 커뮤니티를 위하여 정보 공유를 목적으로 미리 번역한 것입니다. 최신 버전의 내용을 반영하지 못할 수 있으나, 독자 여러분의 기여를 환영합니다. 13 | 14 | 이 문서에 대한 참여를 원하시면 [https://github.com/rkttu/asp-net-blazor-krguide](https://github.com/rkttu/asp-net-blazor-krguide) GitHub 리포지터리를 이용해주세요. 15 | 16 | ## 목차 17 | 18 | * [Blazor 시작하기](get-started.md) 19 | * [첫 Blazor 앱 만들기](tutorials/build-your-first-blazor-app.md) 20 | * [자주 묻는 질문들](faq.md) 21 | * [Blazor 소개](introduction.md) 22 | * [컴포넌트](components.md) 23 | * [레이아웃](layouts.md) 24 | * [의존성 주입](dependency-injection.md) 25 | * [라우팅](routing.md) 26 | * [자바스크립트 연동](javascript-interop.md) 27 | * [호스팅 및 배포](host-and-deploy/) 28 | 29 | -------------------------------------------------------------------------------- /get-started.md: -------------------------------------------------------------------------------- 1 | # Blazor 시작하기 2 | 3 | `노트: Blazor는 아직 기술 지원이 제공되지 않는 실험용 웹 프레임워크로, 실무 개발에 사용되어서는 안됩니다.` 4 | 5 | ## 설치하기 6 | 7 | 다음을 설치하세요: 8 | 9 | 1. [.NET Core 2.1 SDK](https://go.microsoft.com/fwlink/?linkid=873092) \(2.1.402 이상\). 10 | 2. [Visual Studio 2017](https://go.microsoft.com/fwlink/?linkid=873093) \(15.8 이상\)을 _ASP.NET과 웹 개발 워크로드_를 선택하여 함께 설치하세요. 11 | 3. 최신 버전의 [Blazor 언어 서비스 확장팩](https://go.microsoft.com/fwlink/?linkid=870389)을 Visual Studio 마켓플레이스를 통해 설치하세요. 12 | 4. 명령줄 도구에서 다음과 같이 Blazor 템플릿을 설치합니다: 13 | 14 | ```text 15 | dotnet new -i Microsoft.AspNetCore.Blazor.Templates 16 | ``` 17 | 18 | Visual Studio에서 첫 프로젝트를 만들려면: 19 | 20 | 1. **파일** > **새 프로젝트** > **웹** > **ASP.NET Core 웹 애플리케이션**을 선택하세요. 21 | 2. 반드시 **.NET Core**와 **ASP.NET Core 2.1**을 창 위에서 선택하세요. 22 | 3. Blazor 템플릿을 선택하고 **확인**을 누르세요. 23 | 24 | ![New Blazor app dialog](https://msdnshared.blob.core.windows.net/media/2018/07/new-blazor-app-dialog-0.5.0.png) 25 | 26 | 4. 키보드에서 **Ctrl키와 F5키**를 눌러 _디버거 없이 앱을 실행_합니다. 디버거를 연결하여 실행하는 기능 \(**F5**\)은 아직 지원되지 않습니다. 27 | 28 | 명령줄에서 새 Blazor 앱을 만들려면: 29 | 30 | ```text 31 | dotnet new blazor -o BlazorApp1 32 | cd BlazorApp1 33 | dotnet run 34 | ``` 35 | 36 | 축하합니다! 여러분은 이제 첫 Blazor 앱을 실행하셨습니다! 37 | 38 | ![Blazor 앱 홈페이지](https://msdnshared.blob.core.windows.net/media/2018/04/blazor-bootstrap-4.png) 39 | 40 | ## 도움말과 피드백 41 | 42 | 여러분의 피드백은 Blazor의 실험용 버전을 개발하는 데에 매우 요긴하게 사용됩니다. 만약 Blazor를 실행하면서 문제가 발생하거나 질문이 있다면, 꼭 알려주세요! 43 | 44 | * 어떤 종류이든 관계없이 문제가 발생하였거나, 혹은 제안과 개선 사항이 있다면 [GitHub에 이슈를 ](https://github.com/aspnet/blazor/issues)해주세요. 45 | * 만약 문제가 발생하거나 Blazor를 여러분이 원하는대로 동작하도록 수정한 경험이 있다면 Blazor 개발자들과 [Gitter](https://gitter.im/aspnet/blazor) 커뮤니티에서 대화하여 공유해주세요. 46 | 47 | Blazor를 테스트해본 다음에는, 제품과 함께 제공되는 설문 조사에 응답하셔서 여러분의 의견을 알려주세요. 기본 제공되는 Blazor 프로젝트 템플릿을 아무거나 하나 선택하여 앱을 실행하고, 아래 화면과 같이 앱 홈페이지에 있는 설문 조사 링크를 클릭하면 됩니다. 48 | 49 | ![Blazor 설문 조사](https://msdnshared.blob.core.windows.net/media/2018/05/blazor-survey-new.png) 50 | 51 | ## 다음 단계 52 | 53 | [첫 Blazor 앱 만들기](tutorials/build-your-first-blazor-app.md) 54 | 55 | -------------------------------------------------------------------------------- /debugging.md: -------------------------------------------------------------------------------- 1 | # 디버깅 2 | 3 | `노트: Blazor는 아직 기술 지원이 제공되지 않는 실험용 웹 프레임워크로, 실무 개발에 사용되어서는 안됩니다.` 4 | 5 | Blazor는 Chrome에서 WebAssembly로 실행되는 클라이언트 측 Blazor 앱에 대한 _매우 초기 단계의_ 디버깅을 일부 지원합니다. 매우 제한적이고 다듬어지지 않은 초창기 수준의 디버깅 지원이지만, 기본적인 디버깅 인프라가 같이 개발되고 있습니다. 6 | 7 | Chrome에서 클라이언트 측 Blazor 앱을 디버깅하려면: 8 | 9 | * `Debug` 빌드 구성 \(게시되지 않은 앱의 기본 구성\)으로 Blazor 앱을 빌드합니다. 10 | * Blazor 앱을 Chrome에서 실행합니다. 11 | * 앱에 키보드 포커스를 둔 상태에서 \(개발자 도구 패널이 아닙니다. 햇갈리지 않도록 개발자 도구 패널은 닫으시는 것을 권합니다.\), 다음의 Blazor 디버깅 전용 키보드 단축 키를 누릅니다: 12 | * Windows와 Linux에서는 `Shift+Alt+D` 키를 누릅니다. 13 | * macOS에서는 `Shift+Cmd+D` 키를 누릅니다. 14 | 15 | Blazor 앱을 디버깅하려면 Chrome을 원격 디버깅을 활성화한 상태에서 실행합니다. 만약 원격 디버깅이 비활성화되어있으면, Chrome이 오류 페이지를 생성합니다. 오류 페이지에는 Chrome이 디버깅 포트를 연 상태에서 실행하도록 하기 위한 방법이 포함되어있으며, 이를 통해 Blazor 디버깅 프록시가 앱에 연결할 수 있습니다. 안내되어있는대로 _모든 Chrome 인스턴스들을 닫은 후_ Chrome을 다시 시작합니다. 16 | 17 | ![Blazor 디버깅 오류 페이지](https://user-images.githubusercontent.com/1874516/43123091-01ec0796-8ed8-11e8-844c-23b4e6e9d069.png) 18 | 19 | 원격 디버깅을 활성화한 상태에서 Chrome을 실행하면, 디버깅 키보드 단축키가 새로운 디버거 탭을 엽니다. 잠시 후, _Sources_ 탭에는 앱이 사용하는 모든 .NET 어셈블리들의 목록이 표시됩니다. 각 어셈블리를 열어, 사용 가능한 _.cs_\|_.cshtml_ 소스 파일들 중 디버깅하려는 파일을 찾습니다. 중단점을 설정하고, 앱의 탭으로 되돌아와서 중단점을 설정해둔 부분까지 실행합니다. 중단점을 만나면, 한 단계씩 실행 \(`F10`\) 하거나, 정상적으로 계속 실행 \(`F8`\) 합니다. 20 | 21 | ![Blazor 디버깅](https://user-images.githubusercontent.com/1874516/43123060-efb0b3b0-8ed7-11e8-9ea5-97aa34247a0b.png) 22 | 23 | Blazor는 [Chrome DevTools 프로토콜](https://chromedevtools.github.io/devtools-protocol/)을 구현하는, .NET에 특화된 정보를 적절하게 융합하는 디버깅 프록시를 제공합니다. 디버깅 키보드 단축키가 눌러지면 Blazor는 Chrome DevTools를 프록시에서 가리킵니다. 프록시는 디버그하고자하는 브라우저 창에 연결합니다. \(따라서 원격 디버깅을 활성화해야합니다.\) 24 | 25 | 그런데 브라우저 소스 맵을 사용하지 않는 이유가 궁금하실 것입니다. 소스 맵은 브라우저가 컴파일된 파일과 원본 소스 파일 간의 관계를 알 수 있도록 해줍니다. 하지만, Blazor는 C\#과 JS/WASM과 직접 맵핑하는 것을 \(아직까지는\) 지원하지 않습니다. 대신, Blazor는 IL 해석을 브라우저 내에서 처리하므로, 소스 맵과는 관계가 없습니다. 26 | 27 | 또한 디버거 기능은 **매우 제한적**입니다. 다음의 기능만을 사용할 수 있습니다: 28 | 29 | * 실행 중인 메서드 안에서 한 단계씩 진행 \(`F10`\) 또는 계속 실행 \(`F8`\)하기 30 | * _로컬 변수_ 디스플레이에서, `int`, `string`, 그리고 `bool` 형식의 변수에 대한 값 보기 31 | * JavaScript에서 .NET으로 향하거나, .NET에서 JavaScript로 향하는 호출 과정을 포함하는 호출 스택 보기 32 | 33 | _할 수 없는 일_ 들은 다음과 같습니다: 34 | 35 | * 자식 메서드로 진입하여 실행하기 \(`F11`\) 36 | * `int`, `string`, 또는 `bool` 형식이 아닌 다른 모든 형식의 로컬 변수 값 보기 37 | * 클래스 속성이나 필드의 값 보기 38 | * 값을 보기 위하여 변수 위로 마우스 커서 가져가기 39 | * 콘솔에서 식 평가하기 40 | * 비동기 호출 간 전환하기 41 | * 보통의 디버깅 시나리오에서 지원하는 대부분의 기능들 42 | 43 | 더 많은 디버깅 시나리오의 개발은 엔지니어링 팀이 현재 계속 작업하고 있습니다. 44 | 45 | ## 문제 해결 팁 46 | 47 | 만약 오류가 발생하는 경우, 아래 내용이 도움이 될 수 있습니다: 48 | 49 | **디버거** 탭에서, 브라우저의 개발자 도구를 엽니다. 콘솔에서, `localStorage.clear()` 를 실행하여 모든 중단점을 제거합니다. 50 | 51 | -------------------------------------------------------------------------------- /host-and-deploy/configure-linker.md: -------------------------------------------------------------------------------- 1 | # 링커 설정하기 2 | 3 | `노트: Blazor는 아직 기술 지원이 제공되지 않는 실험용 웹 프레임워크로, 실무 개발에 사용되어서는 안됩니다.` 4 | 5 | Blazor performs [Intermediate Language \(IL\)](https://docs.microsoft.com/dotnet/standard/managed-code#intermediate-language--execution) linking during each Release mode build to remove unnecessary IL from the output assemblies. 6 | 7 | You can control assembly linking with either of the following approaches: 8 | 9 | * Disable linking globally with an MSBuild property. 10 | * Control linking on a per-assembly basis with a configuration file. 11 | 12 | ### Disable linking with an MSBuild property 13 | 14 | Linking is enabled by default in Release mode when an app is built, which includes publishing. To disable linking for all assemblies, set the `` MSBuild property to `false` in the project file: 15 | 16 | ```text 17 | 18 | false 19 | 20 | ``` 21 | 22 | ### Control linking with a configuration file 23 | 24 | Linking can be controlled on a per-assembly basis by providing an XML configuration file and specifying the file as an MSBuild item in the project file. 25 | 26 | The following is an example configuration file \(_Linker.xml_\): 27 | 28 | ```text 29 | 30 | 34 | 35 | 36 | 41 | 42 | 43 | 44 | 48 | 49 | 50 | 54 | 55 | 56 | ``` 57 | 58 | To learn more about the file format for the configuration file, see [IL Linker: Syntax of xml descriptor](https://github.com/mono/linker/blob/master/linker/README.md#syntax-of-xml-descriptor). 59 | 60 | Specify the configuration file in the project file with the `BlazorLinkerDescriptor` item: 61 | 62 | ```text 63 | 64 | 65 | 66 | ``` 67 | 68 | -------------------------------------------------------------------------------- /layouts.md: -------------------------------------------------------------------------------- 1 | # 레이아웃 2 | 3 | `노트: Blazor는 아직 기술 지원이 제공되지 않는 실험용 웹 프레임워크로, 실무 개발에 사용되어서는 안됩니다.` 4 | 5 | Blazor apps typically contain more than one page. Layout elements, such as menus, copyright messages, and logos, must be present on all pages. Copying the code of these layout elements into all of the pages of an app isn't an efficient solution. Such duplication is hard to maintain and probably leads to inconsistent content over time. _Layouts_ solve this problem. 6 | 7 | ### What are layouts? 8 | 9 | Technically, a layout is just another Blazor component. A layout is defined in a Razor template or in C\# code and can contain data binding, dependency injection, and other ordinary features of components. Two additional aspects turn a _component_ into a _layout_: 10 | 11 | * The layout component must inherit from [BlazorLayoutComponent](https://blazor.net/api/Microsoft.AspNetCore.Blazor.Layouts.BlazorLayoutComponent.html). `BlazorLayoutComponent` defines a `Body` property that contains the content to be rendered inside the layout. 12 | * The layout component uses the `Body` property to specify where the body content should be rendered using the Razor syntax `@Body`. During rendering, `@Body` is replaced by the content of the layout. 13 | 14 | The following code sample shows the Razor template of a layout component. Note the use of `BlazorLayoutComponent` and `@Body`: 15 | 16 | ```text 17 | @inherits BlazorLayoutComponent 18 | 19 |
20 |

ERP Master 3000

21 |
22 | 23 | 28 | 29 | @Body 30 | 31 | 34 | 35 | @functions { 36 | public string CopyrightMessage { get; set; } 37 | ... 38 | } 39 | ``` 40 | 41 | ### Use a layout in a component 42 | 43 | Use the Razor directive `@layout` to apply a layout to a component. The compiler converts this directive into a [LayoutAttribute](https://blazor.net/api/Microsoft.AspNetCore.Blazor.Layouts.LayoutAttribute.html), which is applied to the component class. 44 | 45 | The following code sample demonstrates the concept. The content of this component is inserted into the _MasterLayout_ at the position of `@Body`: 46 | 47 | ```text 48 | @layout MasterLayout 49 | 50 | @page "/master-data" 51 | 52 |

Master Data Management

53 | ... 54 | ``` 55 | 56 | ### Centralized layout selection 57 | 58 | Every folder of a Blazor app can optionally contain a template file named _\_ViewImports.cshtml_. The compiler includes the directives specified in the view imports file in all of the Razor templates in the same folder and recursively in all of its subfolders. Therefore, a _\_ViewImports.cshtml_ file containing `@layout MainLayout` ensures that all of the components in a folder use the _MainLayout_ layout. There's no need to repeatedly add `@layout` to all of the _\*.cshtml_ files. 59 | 60 | Note that the default template for Blazor apps uses the _\_ViewImports.cshtml_ mechanism for layout selection. A newly created app contains the _\_ViewImports.cshtml_ file in the _Pages_ folder. 61 | 62 | ### Nested layouts 63 | 64 | Blazor apps can consist of nested layouts. A component can reference a layout which in turn references another layout. For example, nesting layouts can be used to reflect a multi-level menu structure. 65 | 66 | The following code samples show how to use nested layouts. The _CustomersComponent.cshtml_ file is the component to display. Note that the component references the layout `MasterDataLayout`. 67 | 68 | _CustomersComponent.cshtml_: 69 | 70 | ```text 71 | @layout MasterDataLayout 72 | 73 | @page "/master-data/customers" 74 | 75 |

Customer Maintenance

76 | ... 77 | ``` 78 | 79 | The _MasterDataLayout.cshtml_ file provides the `MasterDataLayout`. The layout references another layout, `MainLayout`, where it's going to be embedded. 80 | 81 | _MasterDataLayout.cshtml_: 82 | 83 | ```text 84 | @layout MainLayout 85 | @inherits BlazorLayoutComponent 86 | 87 | 91 | 92 | @Body 93 | ``` 94 | 95 | Finally, `MainLayout` contains the top-level layout elements, such as the header, footer, and main menu. 96 | 97 | _MainLayout.cshtml_: 98 | 99 | ```text 100 | @inherits BlazorLayoutComponent 101 | 102 |
...
103 | 104 | 105 | @Body 106 | ``` 107 | 108 | -------------------------------------------------------------------------------- /introduction.md: -------------------------------------------------------------------------------- 1 | # Blazor 소개 2 | 3 | `노트: Blazor는 아직 기술 지원이 제공되지 않는 실험용 웹 프레임워크로, 실무 개발에 사용되어서는 안됩니다.` 4 | 5 | Blazor는 브라우저 안에서 WebAssembly로 실행되는 C\#/Razor와 HTML을 사용하는 실험용 .NET 웹 프레임워크입니다. Blazor는 클라이언트 측에서 .NET을 사용하여 얻을 수 있는 \(부수적으로 서버에서 사용하는 경우까지 포함하여\) 클라이언트 측 웹 UI 프레임워크의 모든 이점을 제공합니다. 6 | 7 | ## 왜 브라우저에서 .NET을 사용합니까? 8 | 9 | 지난 수년간 웹 개발 기술은 다양한 방식으로 개선되어왔지만, 여전히 모던 웹 앱을 만드는 것은 도전적인 면이 있습니다. .NET을 브라우저에서 사용하면 웹 개발을 더 쉽고 더 생산적으로 만드는데 도움을 주는 여러 장점들이 있습니다: 10 | 11 | * **안정성과 일관성**: .NET은 여러 플랫폼에 걸쳐서 안정적이고, 풍분한 기능을 제공하며, 사용하기 쉬운 표준화된 프로그래밍 프레임워크를 제공합니다. 12 | * **혁신적인 모던 프로그래밍 언어**: .NET의 언어들은 혁신적인 새로운 언어 기능과 함께 꾸준히 개선되어 왔습니다. 13 | * **업계 표준의 도구**: Visual Studio 제품군은 환상적인 .NET 개발 환경을 Windos, Linux, 그리고 macOS에 대해 제공합니다. 14 | * **속도와 확장성**: .NET은 앱 개발을 위한 성능, 안정성, 그리고 보안에 대한 강한 기반을 가지고 있습니다. .NET을 풀 스택 솔루션으로 사용하면 빠르고, 안정적이며, 안전한 앱을 만드는 것이 더 쉬워집니다. 15 | * **기존 스킬을 활용하는 풀 스택 개발**: C\#/Razor 개발자는 기존의 C\#/Razor 스킬을 이용하여 클라이언트 측 코드를 작성하고, 서버와 클라이언트 로직을 앱 간에 공유할 수 있습니다. 16 | * **폭 넓은 브라우저 지원**: Blazor는 별도의 플러그인이나 코드 변환없이 브라우저에서 공개 웹 표준을 사용하여 실행되는 환경 위의 .NET에서 실행됩니다. 모바일 브라우저를 포함한 모든 최신 웹 브라우저에서 동작합니다. 17 | 18 | ## Blazor가 브라우저 안에서 .NET을 실행하는 원리 19 | 20 | 웹 브라우저 안에서 .NET 코드를 실행하는 것은 비교적 최신 기술인 [WebAssembly](http://webassembly.org/) \(이하 _wasm_ 으로 표기합니다.\) 덕분에 가능했습니다. WebAssembly는 공개 웹 표준으로 플러그인 없이 브라우저 안에서 사용할 수 있습니다. WebAssembly는 빠른 다운로드와 실행 속도에 최적화된 최소한의 바이트코드 포맷입니다. 21 | 22 | WebAssembly 코드는 JavaScrpt 연동을 통하여 브라우저의 모든 기능에 접근할 수 있습니다. 동시에, WebAssembly 코드는 JavaScript가 실행되는 것과 동일한 안전한 샌드박스 안에서 실행되어, 클라이언트 장치에 위협을 줄 수 있는 동작이 차단됩니다. 23 | 24 | Blazor 앱을 만들고 브라우저 안에서 실행할 때에는: 25 | 26 | 1. C\# 코드 파일과 Razor 파일이 .NET 어셈블리로 컴파일됩니다. 27 | 2. 브라우저가 어셈블리와 .NET 런타임을 다운로드합니다. 28 | 3. Blazor는 JavaScript를 사용하여 .NET 런타임을 초기화하고, 필요한 어셈블리들을 불러들이도록 런타임을 구성합니다. 문서 개체 모델 \(DOM\) 을 조작하고 브라우저 API 호출을 JavaScript 상호 연동을 통하여 Blazor가 처리하게 됩니다. 29 | 30 | WebAssembly를 지원하지 않는 오래된 브라우저를 지원하기 위하여, Blazor는 [asm.js](https://wikipedia.org/wiki/Asm.js) 기반의 .NET 런타임을 대신 사용합니다. 31 | 32 | ## Blazor 컴포넌트 33 | 34 | Blazor 앱은 _컴포넌트_ 들로 구성됩니다. 하나의 컴포넌트는 페이지, 대화 상자, 또는 데이터 입력 양식과 같은 UI 조각입니다. 컴포넌트는 중첩되거나, 재사용되거나, 프로젝트 간에 공유될 수 있습니다. 35 | 36 | Blazor에서, 컴포넌트는 .NET 클래스입니다. 클래스는 C\# 클래스 \(_\*.cs_\) 로 직접 작성되거나, 혹은 더 많이 사용되는 형태로 Razor 마크업 페이지 \(_\*.cshtml_\)를 통하여 만들어 질 수 있습니다. 37 | 38 | [Razor](https://docs.microsoft.com/aspnet/core/mvc/views/razor) 는 C\# 코드와 HTML 마크업을 결합한 문법입니다. Razor는 개발자가 마크업와 C\#을 한 파일 안에서 [IntelliSense](https://docs.microsoft.com/visualstudio/ide/using-intellisense)를 사용하여 번갈아가며 사용할 수 있도록, 개발자의 생산성을 위하여 설계되었습니다. 다음은 _DialogComponent.cshtml_ Razor 파일 안에 정의한 기본적인 커스텀 대화 상자 마크업의 예시입니다: 39 | 40 | ```text 41 |
42 |

@Title

43 | @BodyContent 44 | 45 |
46 | 47 | @functions { 48 | public string Title { get; set; } 49 | public RenderFragment BodyContent { get; set; } 50 | public Action OnOK { get; set; } 51 | } 52 | ``` 53 | 54 | 이 컴포넌트가 앱 안의 다른 위치에서 사용될 때, IntelliSense는 문법과 파라미터 자동 완성을 지원해줍니다. 55 | 56 | 컴포넌트는 다음과 같은 특징이 있습니다: 57 | 58 | * 중첩 가능합니다. 59 | * Razor \(_\*.cshtml_\) 또는 C\# \(_\*.cs_\) 코드로 만들 수 있습니다. 60 | * 클래스 라이브러리를 통하여 공유할 수 있습니다. 61 | * 브라우저 DOM 없이 단위 테스트를 만들 수 있습니다. 62 | 63 | ## 구조 64 | 65 | Blazor는 대부분의 앱이 필요로 하는 다음과 같은 내부 기능들을 제공합니다: 66 | 67 | * 레이아웃 68 | * 라우팅 69 | * 의존성 주입 70 | 71 | 이 기능들은 모두 부수적으로 사용할 수 있습니다. 앱에서 사용하지 않는 기능이 있으면, 앱이 나중에 [중간 언어 \(IL\) 링커](https://blazor.net/docs/host-and-deploy/configure-linker.html)를 통하여 내보내질 때 해당 기능의 구현이 제거된 채로 내보내집니다. 72 | 73 | ## 코드 공유와 .NET Standard 74 | 75 | Blazor 앱은 기존의 [.NET Standard](https://docs.microsoft.com/dotnet/standard/net-standard) 라이브러리를 참조하여 사용할 수 있습니다. .NET Standard는 여러 .NET 구현체들간의 공통된 일반화된 .NET API들의 사양입니다. Blazor는 .NET Standard 2.0 및 이후 버전을 지원합니다. 웹 브라우저 안에서 사용할 수 없는 API들 \(예를 들어, 파일 시스템에 접근하거나, 소켓을 열거나, 다중 스레드를 다루는 등\) 을 사용하려고 하면 [PlatformNotSupportedException](https://docs.microsoft.com/dotnet/api/system.platformnotsupportedexception) 예외가 발생합니다. .NET Standard 클래스 라이브러리들은 서버 코드와 브라우저 기반 앱 간에 공유할 수 있습니다. 76 | 77 | ## JavaScript 연동 78 | 79 | 서드파티 JavaScript 라이브러리와 브라우저 API가 필요한 앱을 위하여, WebAssembly는 JavaScript와 연동할 수 있도록 설계되어있습니다. Blazor는 모든 JavaScript 라이브러리와 API를 사용할 수 있습니다. C\# 코드는 JavaScript 코드를 호출할 수 있으며, JavaScript 코드는 C\# 코드를 호출할 수 있습니다. 더 자세한 정보는, [JavaScript 연동](javascript-interop.md) 문서를 참고하세요. 80 | 81 | ## 최적화 82 | 83 | 클라이언트 측 앱의 경우, 데이터 다운로드 크기는 매우 중요한 문제입니다. Blazor는 다운로드 크기를 최적화하여 다운로드 시간을 최소화합니다. 예를 들어, .NET 어셈블리에서 사용되지 않는 부분을 빌드 과정 중에 제거합니다. 그리고 HTTP 압축을 사용하거나, .NET 런타임과 어셈블리는 브라우저에서 캐시할 수 있습니다. 84 | 85 | ## 배포 86 | 87 | Blazor를 사용하여 완전히 독립된 클라이언트 측 앱을 만들거나, 서버와 클라이언트 앱을 모두 포함하는 풀 스택 ASP.NET Core 앱을 만들 수 있습니다. 88 | 89 | * **독립된 클라이언트 측 앱**을 만들면, Blazor 앱은 _dist_ 폴더 안에 정적 파일들로만 구성된 형태로 컴파일됩니다. 이 파일들은 Azure App Service, GitHub Pages, IIS \(정적 파일 제공 기능을 활성화해야 합니다.\), Node.js 서버, 그리고 수많은 서버와 서비스들 위에서 호스팅할 수 있습니다. 이 방식에서 서버에 .NET 런타임은 필요하지 않습니다. 90 | * **풀 스택 ASP.NET Core 앱**을 만들면, 코드를 서버와 클라이언트에서 공유할 수 있습니다. 만들어지는 ASP.NET Core 서버 앱은 Blazor의 클라이언트 측 UI과 서버 사이트 API 엔드포인트를 제공하며, ASP.NET Core를 지원하는 환경이라면 클라우드와 온 프레미스 환경 어디서나 실행 가능합니다. 91 | 92 | -------------------------------------------------------------------------------- /host-and-deploy/hosting-models.md: -------------------------------------------------------------------------------- 1 | # 호스팅 모델 2 | 3 | `노트: Blazor는 아직 기술 지원이 제공되지 않는 실험용 웹 프레임워크로, 실무 개발에 사용되어서는 안됩니다.` 4 | 5 | 6 | 7 | Blazor is a client-side web framework designed primarily to run in the browser on a WebAssembly-based .NET runtime. Blazor supports multiple hosting models, including out-of-process hosting models, where the Blazor component logic runs separately from the UI thread. Regardless of the hosting model, the Blazor app and component models remain _the same_. This article discusses the available hosting models for Blazor. 8 | 9 | ### Client-side hosting model 10 | 11 | The principal hosting model for Blazor is running client-side in the browser. In this model, the Blazor app, its dependencies, and the .NET runtime are downloaded to the browser, and the app is executed directly on the browser UI thread. All UI updates and event handling happens within the same process. The app assets can be deployed as static files using whatever web server is preferred \(see [Host and deploy](https://blazor.net/docs/host-and-deploy/index.html)\). 12 | 13 | ![Blazor client-side](https://user-images.githubusercontent.com/1874516/43042852-998bb680-8d3b-11e8-9d39-adf8d3d77360.png) 14 | 15 | To create a Blazor app using the client-side hosting model, use the **Blazor** or **Blazor \(ASP.NET Core Hosted\)** project templates \(`blazor` or `blazorhosted` template when using [dotnet new](https://blazor.net/dotnet/core/tools/dotnet-new) at a command prompt\). The included _blazor.webassembly.js_ script handles: 16 | 17 | * Downloading the .NET runtime, the app, and its dependencies. 18 | * Initialization of the runtime to run the app. 19 | 20 | The benefits of the client-side hosting model are: 21 | 22 | * No .NET server-side dependency 23 | * Rich interactive UI 24 | * Fully leverage the client resources and capabilities 25 | * Offload work from the server to the client 26 | * Support offline scenarios 27 | 28 | The downsides to the client-side hosting model are: 29 | 30 | * Restricted to the capabilities of the browser 31 | * Requires more capable client hardware and software \(for example, WebAssembly support\) 32 | * Larger download size and app load time 33 | * Less mature .NET runtime and tooling support \(for example, limitations in .NET Standard support and debugging\) 34 | 35 | **NOTE** 36 | 37 | Visual Studio includes the **Blazor \(ASP.NET Core hosted\)** project template for creating a Blazor app that runs on WebAssembly and is hosted on an ASP.NET Core server. The ASP.NET Core app serves the Blazor app to clients but is otherwise a separate process. The client-side Blazor app can interact with the server over the network using Web API calls or SignalR connections. 38 | 39 | **IMPORTANT** 40 | 41 | If a client-side Blazor app is served by an ASP.NET Core app hosted as an IIS sub-app, it's important to disable the inherited ASP.NET Core Module handler. Remove the handler in the Blazor app's published _web.config_ file by adding a `` section to the file: 42 | 43 | ```text 44 | 45 | 46 | 47 | ``` 48 | 49 | Set the app base path in the Blazor app's _index.html_ file to the IIS alias used when configuring the sub-app in IIS. For more information, see [App base path](https://blazor.net/docs/host-and-deploy/index.html#app-base-path). 50 | 51 | ### Server-side hosting model 52 | 53 | In the server-side hosting model, Blazor is executed on the server from within an ASP.NET Core app. UI updates, event handling, and JavaScript calls are handled over a SignalR connection. 54 | 55 | ![Blazor server-side](https://user-images.githubusercontent.com/1874516/43042867-eaa8bb76-8d3b-11e8-8f1d-60768f86f710.png) 56 | 57 | To create a Blazor app using the server-side hosting model, use the **Blazor \(Server-side on ASP.NET Core\)** template \(`blazorserver` when using [dotnet new](https://blazor.net/dotnet/core/tools/dotnet-new) at a command prompt\). An ASP.NET Core app hosts the Blazor server-side app and sets up the SignalR endpoint where clients connect. The ASP.NET Core app references the Blazor `Startup` class to both add the server-side Blazor services and to add the Blazor app to the request handling pipeline: 58 | 59 | ```text 60 | public class Startup 61 | { 62 | public void ConfigureServices(IServiceCollection services) 63 | { 64 | ... 65 | services.AddServerSideBlazor(); 66 | } 67 | 68 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 69 | { 70 | ... 71 | app.UseServerSideBlazor(); 72 | } 73 | } 74 | ``` 75 | 76 | The _blazor.server.js_ script establishes the client connection. It's the app's responsibility to persist and restore app state as needed \(for example, in the event of a lost network connection\). 77 | 78 | The benefits of the server-side hosting model are: 79 | 80 | * You can still write your entire app with .NET and C\# using the Blazor component model. 81 | * Your app still has a rich interactive feel and avoids unnecessary page refreshes. 82 | * Your app download size is significantly smaller, and the initial app load time is much faster. 83 | * Your Blazor component logic can take full advantage of server capabilities, including using any .NET Core compatible APIs. 84 | * Because you're running on .NET Core on the server, existing .NET tooling, such as debugging, works as expected. 85 | * Server-side hosting works with thin clients \(for example, browsers that don't support WebAssembly and resource constrained devices\). 86 | 87 | The downsides of the server-side hosting model are: 88 | 89 | * Latency: every user interaction now involves a network hop. 90 | * No offline support: if the client connection goes down, the app stops working. 91 | * Scalability: the server must manage multiple client connections and handle client state. 92 | 93 | -------------------------------------------------------------------------------- /routing.md: -------------------------------------------------------------------------------- 1 | # 라우팅 2 | 3 | `노트: Blazor는 아직 기술 지원이 제공되지 않는 실험용 웹 프레임워크로, 실무 개발에 사용되어서는 안됩니다.` 4 | 5 | Learn how to route requests in a client-side Blazor app and about the NavLink component. 6 | 7 | [View or download sample code](https://github.com/aspnet/Blazor.Docs/tree/master/docs/common/samples/) \([how to download](https://blazor.net/docs/index.html#view-and-download-samples)\). See the [Get started](https://blazor.net/docs/get-started.html) topic for prerequisites. 8 | 9 | ### Route templates 10 | 11 | The `` component enables routing, and a route template is provided to each accessible component. The `` component appears in the _App.cshtml_ file: 12 | 13 | ```text 14 | 15 | ``` 16 | 17 | When a _\*.cshtml_ file with an `@page` directive is compiled, the generated class is given a [RouteAttribute](https://docs.microsoft.com/dotnet/api/microsoft.aspnetcore.mvc.routeattribute) specifying the route template. At runtime, the router looks for component classes with a `RouteAttribute` and renders whichever component has a route template that matches the requested URL. 18 | 19 | Multiple route templates can be applied to a component. In the [sample app](https://github.com/aspnet/Blazor.Docs/tree/master/docs/common/samples/), the following component responds to requests for `/BlazorRoute` and `/DifferentBlazorRoute`. 20 | 21 | _Pages/BlazorRoute.cshtml_: 22 | 23 | ```text 24 | @page "/BlazorRoute" 25 | @page "/DifferentBlazorRoute" 26 | 27 |

Blazor routing

28 | ``` 29 | 30 | **IMPORTANT** 31 | 32 | To generate routes properly, the app must include a `` tag in its _wwwroot/index.html_ file with the app base path specified in the `href` attribute \(``\). For more information, see [Host and deploy: App base path](https://blazor.net/docs/host-and-deploy/index.html#app-base-path). 33 | 34 | ### Route parameters 35 | 36 | The Blazor client-side router uses route parameters to populate the corresponding component parameters with the same name \(case insensitive\). 37 | 38 | _Pages/RouteParameter.cshtml_: 39 | 40 | ```text 41 | @page "/RouteParameter" 42 | @page "/RouteParameter/{text}" 43 | 44 |

Blazor is @Text!

45 | 46 | @functions { 47 | [Parameter] 48 | private string Text { get; set; } = "fantastic"; 49 | ``` 50 | 51 | Optional parameters aren't supported yet, so two `@page` directives are applied in the example above. The first permits navigation to the component without a parameter. The second `@page`directive takes the `{text}` route parameter and assigns the value to the `Text` property. 52 | 53 | ### Route constraints 54 | 55 | A route constraint enforces type matching on a route segment to a Blazor component. 56 | 57 | In the following example, the route to the Users component only matches if: 58 | 59 | * An `Id` route segment is present on the request URL. 60 | * The `Id` segment is an integer \(`int`\). 61 | 62 | ```text 63 | @page "/Users/{Id:int}" 64 | 65 |

The user Id is @Id!

66 | 67 | @functions { 68 | [Parameter] 69 | private int Id { get; set; } 70 | } 71 | ``` 72 | 73 | The route constraints shown in the following table are available for use. For the route constraints that match with the invariant culture, see the warning below the table for more information. 74 | 75 | | Constraint | Example | Example Matches | Invariant culture matching | 76 | | :--- | :--- | :--- | :--- | 77 | | `bool` | `{active:bool}` | `true`, `FALSE` | No | 78 | | `datetime` | `{dob:datetime}` | `2016-12-31`, `2016-12-31 7:32pm` | Yes | 79 | | `decimal` | `{price:decimal}` | `49.99`, `-1,000.01` | Yes | 80 | | `double` | `{weight:double}` | `1.234`, `-1,001.01e8` | Yes | 81 | | `float` | `{weight:float}` | `1.234`, `-1,001.01e8` | Yes | 82 | | `guid` | `{id:guid}` | `CD2C1638-1638-72D5-1638-DEADBEEF1638`, `{CD2C1638-1638-72D5-1638-DEADBEEF1638}` | No | 83 | | `int` | `{id:int}` | `123456789`, `-123456789` | Yes | 84 | | `long` | `{ticks:long}` | `123456789`, `-123456789` | Yes | 85 | 86 | **WARNING** 87 | 88 | Route constraints that verify the URL and are converted to a CLR type \(such as `int` or `DateTime`\) always use the invariant culture. These constraints assume that the URL is non-localizable. 89 | 90 | ### NavLink component 91 | 92 | Use a NavLink component in place of HTML **<a>** elements when creating navigation links. A NavLink component behaves like an **<a>** element, except it toggles an `active` CSS class based on whether its `href` matches the current URL. The `active` class helps a user understand which page is the active page among the navigation links displayed. 93 | 94 | The NavMenu component in the [sample app](https://github.com/aspnet/Blazor.Docs/tree/master/docs/common/samples/) creates a [Bootstrap](https://getbootstrap.com/docs/) nav bar that demonstrates how to use NavLink components. The following markup shows the first two NavLinks in the _Shared/NavMenu.cshtml_ file. 95 | 96 | ```text 97 |