🎓 All Courses | 📚 Blazor WASM Syllabus
Stickipedia University
📋 Study this course on TaskLoco

Razor directives are special instructions prefixed with @ that control how a component compiles, behaves, and interacts with the framework.

Essential Directives

  • @page "/route" — defines a navigable route for the component
  • @code { } — C# code block for fields, properties, and methods
  • @inject TypeName Identifier — injects a DI service
  • @using Namespace — adds a using statement
  • @inherits BaseClass — sets a base class for the component
  • @implements IInterface — declares an interface implementation
  • @attribute [Attribute] — applies a C# attribute to the component class
  • @typeparam T — makes the component generic
  • @layout LayoutName — overrides the default layout
  • @namespace MyApp.Pages — sets the component namespace
  • @rendermode — sets the render mode (Blazor 8+)

_Imports.razor

Add common @using and @inject statements to _Imports.razor — they apply to all components in the same folder and subfolders. This eliminates repetitive using statements at the top of every file.


YouTube • Top 10
Blazor WASM: Razor Directives Reference
Tap to Watch ›
📸
Google Images • Top 10
Blazor WASM: Razor Directives Reference
Tap to View ›

Reference:

Wikipedia: Razor

image for linkhttps://en.wikipedia.org/wiki/Blazor

📚 Blazor WASM — Full Course Syllabus
📋 Study this course on TaskLoco

TaskLoco™ — The Sticky Note GOAT