ASP.NET Core Blazor Server Demo
The ASP.NET Core Blazor Server Demo is functionally identical to the ASP.NET Core Razor Server Demo — it provides the same streaming functionality as the .NET Server Demo with the same sample classes, protocol support, and WebTransport playback page. The difference is that this demo shows how to integrate the streaming server into the Blazor infrastructure using interactive server-side Razor components instead of Razor Pages.
Differences from the Razor Demo
The only differences from the ASP.NET Core Razor Server Demo are in the application setup:
Service Registration
builder.Services.AddControllers();
builder.Services.AddRazorPages();
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
AddRazorComponents with AddInteractiveServerComponents registers the Blazor Server infrastructure, enabling interactive server-side rendering via SignalR.
Routing and Rendering
app.UseStaticFiles();
app.UseRouting().UseAntiforgery().UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.MapRazorPages();
endpoints
.MapRazorComponents<VAST.Demo.Components.App>()
.AddInteractiveServerRenderMode();
});
app.UseWebSockets(new WebSocketOptions());
MapRazorComponents maps the root App component and AddInteractiveServerRenderMode enables interactive server-side rendering. UseAntiforgery is required by Blazor's form handling.
Blazor Components
The demo uses Blazor's component model instead of Razor Pages for the UI:
| Component | Description |
|---|---|
App.razor |
Root component with HTML document structure and Blazor script reference |
MainLayout.razor |
Application layout with navigation |
NavMenu.razor |
Navigation sidebar |
Home.razor |
Landing page with link to HLS playback |
The Home.razor component serves as the landing page:
@page "/"
<PageTitle>Home</PageTitle>
<h1>Test HLS page</h1>
<p>
Please uncomment sample #8, #9 or #10 in the constructor of
MultiProtoServer first, then click the link below: <br />
<a href="/hls.html?publishingPath=builtin">Watch builtin publishing point</a>
</p>
HTTP Request Dispatching
The HTTP request dispatching to the VASTreaming engine is the same as in the Razor demo:
app.Run(async (context) =>
{
await sample.HttpDispatcher.DispatchRequest(
new VAST.HTTP.AspHttpRequestContext(context));
});
The dispatching approach shown above is just an example. You can implement your own dispatching scenarios based on ASP.NET Core routing, middleware branching, path matching, or any other logic to control which requests are forwarded to the streaming engine.
Everything Else
All other aspects are identical to the ASP.NET Core Razor Server Demo:
- Sample classes — same MultiProtoServer, standalone servers, send/receive samples, file reader/writer samples
- Hosting options — Kestrel and IIS via the
VAST_HTTP_SERVERenvironment variable - WebTransport — same configuration, available on Kestrel only, requires .NET 9+ and TLS with HTTP/3
- API controller — same
SiteApiControllerat/siteApi/v1/displayText - Setup — same license key configuration and environment variable setup
For full details on these topics, see the ASP.NET Core Razor Server Demo.
See Also
- Sample Applications — overview of all demo projects
- ASP.NET Core Razor Server Demo — equivalent demo using Razor Pages
- .NET Server Demo — detailed documentation for all sample classes