Foundations in Blazor
Foundations is the first chapter of the free Blazor tutorial. It explains what Blazor is and takes you to a running Blazor app on your own computer.
What each lesson covers:
- Getting Started: What Blazor is, why teams use it, its key features, its place in .NET, versions, real uses, pros and cons, system requirements, installing the .NET SDK, setting up Visual Studio or VS Code, and creating your first project.
- Project Structure and Running the App: What every file and folder in a new Blazor Web App does, and how to run the app from the IDE or the CLI with Hot Reload.
- Razor Syntax: How Razor mixes HTML and C#: the @ symbol, @code blocks, expressions, raw HTML, @if, @switch, loops, comments and @using.
Every lab on these pages compiles your Razor components with the real Razor compiler and Roslyn, and renders them with Blazor on .NET 10, all inside your browser. Edit the code, press Run, and see the page and the console.
You need no setup to start. The lessons also show you how to install the tools and create the same project on your own computer.
Lessons in this section
- Getting Started
What Blazor is and why teams use it, its key features, its place in .NET, versions, real uses, pros and cons, system requirements, installing the .NET SDK, setting up Visual Studio or VS Code, and creating your first Blazor Web App.
- Explain what Blazor is and why a C# team might choose it
- Install the .NET 10 SDK and set up Visual Studio or VS Code
- Create a Blazor Web App and pick an interactivity option
- Recognise the sample pages the template creates
- Project Structure and Running the App
What every file and folder in a new Blazor Web App does: the .csproj, Program.cs, App.razor, _Imports.razor, wwwroot, the Components and Pages folders and launchSettings.json. Then how to run the app from the IDE or the CLI, and Hot Reload.
- Name the job of the .csproj, Program.cs, App.razor and _Imports.razor
- Know where pages, reusable components and static files go
- Read launchSettings.json and find the app's web address
- Run the app from the IDE or the CLI, and use Hot Reload
- Razor Syntax
How Razor mixes HTML and C#: the @ symbol and escaping it, @code blocks with variables and methods, implicit and explicit expressions, raw HTML with MarkupString, @if, @switch and loops, comments, @using and @namespace.
- Use @ to put C# values into HTML, and @@ to show a real @
- Write variables and methods in an @code block
- Choose between implicit and explicit expressions
- Show or repeat HTML with @if, @switch and loops