Blazor Web Apps in Production: Security, Performance & Deployment Checklist

Gulab Chand Tejwani
PMP · PL-300 · Microsoft Certified Trainer
· 6 min read

A production-ready Blazor app needs more than working components. Before go-live, check that authentication and authorisation are enforced on the server, secrets stay out of the browser, rendering is efficient (virtualised lists, prerendering, trimmed WebAssembly payloads), components and APIs have automated tests, the host supports WebSockets if you use Interactive Server, and logging and health checks are in place. This post is the checklist I use, organised in the order problems usually appear.
At TechNet Consultancy we build Blazor apps for clients and teach Blazor to .NET developers in Anand and online. Most production issues we've debugged came from a handful of skipped steps, not from Blazor itself.
What is a Blazor Web App?
Blazor is Microsoft's framework for building web UIs with C# and Razor components instead of JavaScript. Since .NET 8 the default template is the Blazor Web App, where pages render as static HTML on the server by default and you add interactivity per page or component using the Interactive Server, Interactive WebAssembly or Interactive Auto render modes. If you're still choosing a model, read Blazor WebAssembly vs Server first.
How should you structure a Blazor project?
- Keep components small and focused. Split pages into child components once a file gets hard to read.
- Put business logic in services behind interfaces, injected with dependency injection, not in
.razorfiles. This makes testing easier and lets the same component work in Server and WebAssembly modes. - Share models and validation (data annotations or FluentValidation) in a class library used by both the UI and the API.
- Use a component library (MudBlazor, Radzen, Fluent UI Blazor) deliberately, and don't mix several.
How do you secure a Blazor app?
- Authentication: use ASP.NET Core Identity or an external identity provider such as Microsoft Entra ID. Protect pages with
[Authorize]and show or hide UI with<AuthorizeView>. - Authorisation on the server, always. Hiding a button isn't security. In WebAssembly, users can read and change anything in the browser, so the API must check permissions on every call.
- No secrets in the client. Connection strings, API keys and signing keys belong on the server or in Azure Key Vault.
- HTTPS and HSTS on, plus a sensible Content Security Policy.
- Antiforgery: the .NET 8+ Blazor Web App template includes antiforgery middleware for forms. Keep it enabled.
- Validate input on both client and server.
How do you make Blazor fast?
- Use
<Virtualize>for long lists and grids so only visible rows render. - Use
@keyon items in loops to help the diffing algorithm. - Avoid unnecessary re-renders: don't call
StateHasChangedin loops, and overrideShouldRenderfor expensive components. - Use prerendering and, in .NET 8+, streaming rendering so users see content while data loads.
- For WebAssembly, keep trimming on, enable Brotli compression on the host, lazy-load assemblies you don't need on the first page, and consider ahead-of-time (AOT) compilation for CPU-heavy work (it increases download size).
- For Interactive Server, keep per-user state small, because it lives in server memory for every circuit.
How should you test a Blazor app?
- Unit tests for services with xUnit or NUnit.
- Component tests with bUnit, which renders Razor components in a test and lets you click buttons and check the markup.
- End-to-end tests with Playwright for the critical journeys, such as login, checkout and the main forms.
- Run tests in your CI pipeline (GitHub Actions or Azure DevOps) on every pull request.
How do you debug Blazor problems?
Use Visual Studio or VS Code breakpoints for both Server and WebAssembly (WebAssembly debugging works through the browser's debugging protocol). Turn on detailed errors only in development. For Interactive Server, watch for circuit disconnects in the logs. They often point to proxies that don't support WebSockets or to unhandled exceptions that kill the circuit.
Where should you host a Blazor app?
- Azure App Service: straightforward for Blazor Web Apps. For Interactive Server, enable WebSockets and turn on ARR affinity (sticky sessions) if you run more than one instance, or use Azure SignalR Service.
- Azure Static Web Apps or any CDN: good for standalone Blazor WebAssembly apps.
- IIS on Windows Server: install the ASP.NET Core Hosting Bundle and the WebSocket Protocol feature.
- Linux with Docker and Nginx: configure Nginx to proxy WebSocket upgrade headers, or Interactive Server will fall back to slower transports or fail.
Embedding reports? See our guide to embedding Power BI in Blazor.
What should you monitor after deployment?
- Application Insights or OpenTelemetry for requests, exceptions and performance.
- ASP.NET Core health checks for the database and external APIs.
- Circuit counts and server memory for Interactive Server apps.
- Dependency updates. Plan upgrades to new .NET versions and keep an eye on support dates, since LTS and STS releases have different support lengths.
TechNet Consultancy's Blazor training covers this end to end, and our team builds production Blazor apps as part of our software development services.
FAQ
Is Blazor ready for production?
Yes. Blazor has shipped as part of ASP.NET Core since .NET Core 3.0 in 2019 (Server) and 3.2 in 2020 (WebAssembly), and it's used for internal and public applications.
Why does my Blazor Server app keep disconnecting?
Common causes are proxies or load balancers that block WebSockets, missing sticky sessions when running multiple instances, idle timeouts, and unhandled exceptions that end the circuit.
How do I make Blazor WebAssembly load faster?
Keep trimming enabled, serve Brotli-compressed files, lazy-load assemblies not needed at startup, cache static assets, and consider the Interactive Auto render mode so the first view comes from the server.
How do I test Blazor components?
Use bUnit for component tests and Playwright for end-to-end browser tests, alongside standard unit tests for services.
Can I host Blazor on Linux?
Yes. ASP.NET Core runs on Linux, commonly in Docker behind Nginx. Make sure the reverse proxy forwards WebSocket connections for Interactive Server.