Share via

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:

  1. Download and unzip the sample.
  2. In Visual Studio (2022 or later):
    1. On the menu bar, choose File > Open > Project/Solution.
    2. Navigate to the folder that holds the unzipped sample code, and open the C# project (.csproj) file.
    3. Choose the F5 key to run with debugging, or Ctrl+F5 keys to run the project without debugging.
  3. From the command line:
    1. Navigate to the folder that holds the unzipped sample code.
    2. 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:

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.