Orleans ASP.NET Core Blazor WebAssembly sample
This sample demonstrates how to integrate ASP.NET Core Blazor with Microsoft Orleans. This demonstrates the in-browser Blazor WebAssembly hosting model.
The client-side sample application leverages ASP.NET Web API running alongside Orleans for standard web communication.
The application is based on the official tutorial, adapted to showcase integration with Orleans.
Sample prerequisites
This sample is written in C# and targets .NET 9.0. It requires the .NET 9.0 SDK or later.
Building the sample
To download and run the sample, follow these steps:
- Download and unzip the sample.
- In Visual Studio (2022 or later):
- On the menu bar, choose File > Open > Project/Solution.
- Navigate to the folder that holds the unzipped sample code, and open the C# project (.csproj) file.
- Choose the F5 key to run with debugging, or Ctrl+F5 keys to run the project without debugging.
- From the command line:
- Navigate to the folder that holds the unzipped sample code.
- At the command line, type
dotnet run
.
Running the sample
Run the sample by opening two terminal windows and executing the following in one terminal:
dotnet run --project BlazorWasm.Server
Execute the following in the other terminal:
dotnet run --project BlazorWasm.Client
Once both applications appear to have started, you can access them at these addresses:
- The Swagger UI, hosted by the BlazorWasm.Server process: http://localhost:5000/swagger/index.html
- The Client-Side Blazor App hosted by the BlazorWasm.Client process: http://localhost:62654/
Demos
The application showcases three demos:
Counter
Shows a button that updates a counter. This demonstrates basic logic in Blazor. This demo does not integrate with Orleans.
Fetch Data
A page that fetches read-only data from Orleans. The client-side app sources this data from the ASP.NET Core Web API running alongside Orleans.
Todo
A page that manages a todo list. Allows creating, editing and removing todo items.
The client-side app manages this data via REST calls to the ASP.NET Core Web API running alongside Orleans.