BlazorFrame 2.1.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package BlazorFrame --version 2.1.0
NuGet\Install-Package BlazorFrame -Version 2.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BlazorFrame" Version="2.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BlazorFrame" Version="2.1.0" />
<PackageReference Include="BlazorFrame" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BlazorFrame --version 2.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: BlazorFrame, 2.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BlazorFrame@2.1.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BlazorFrame&version=2.1.0
#tool nuget:?package=BlazorFrame&version=2.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
BlazorFrame
A security-first Blazor iframe component with automatic resizing, cross-frame messaging, and comprehensive Content Security Policy integration.
Features
- Security-First Design - Built-in origin validation, message filtering, and sandbox isolation
- Content Security Policy - Comprehensive CSP integration with fluent configuration API
- Cross-Frame Messaging - Secure postMessage communication with validation
- Sandbox Support - Multiple security levels from permissive to paranoid isolation
- Environment-Aware - Different configurations for development vs production
- Automatic Resizing - Smart height adjustment based on iframe content
Documentation
🚀 Quick Start
Installation
dotnet add package BlazorFrame
Basic Usage
@using BlazorFrame
<BlazorFrame Src="https://example.com" />
<BlazorFrame Src="https://widget.example.com"
SecurityOptions="@securityOptions"
OnValidatedMessage="HandleMessage"
OnSecurityViolation="HandleViolation" />
@code {
private readonly MessageSecurityOptions securityOptions = new MessageSecurityOptions()
.ForProduction() // Strict security settings
.WithBasicSandbox() // Enable iframe sandboxing
.RequireHttps(); // Enforce HTTPS transport
private Task HandleMessage(IframeMessage message)
{
Console.WriteLine($"Received message from {message.Origin}: {message.Data}");
return Task.CompletedTask;
}
private Task HandleViolation(IframeMessage violation)
{
Console.WriteLine($"Security violation: {violation.ValidationError}");
return Task.CompletedTask;
};
}
Configuration Examples
// Development environment - relaxed security
var devOptions = new MessageSecurityOptions()
.ForDevelopment()
.WithPermissiveSandbox();
// Production environment - strict security
var prodOptions = new MessageSecurityOptions()
.ForProduction()
.WithStrictSandbox()
.ValidateAndThrow();
// Payment widgets - maximum security
var paymentOptions = new MessageSecurityOptions()
.ForPaymentWidget();
Content Security Policy
<BlazorFrame Src="https://widget.example.com"
CspOptions="@cspOptions"
OnCspHeaderGenerated="HandleCspGenerated" />
@code {
private readonly CspOptions cspOptions = new CspOptions()
.ForProduction()
.AllowFrameSources("https://widget.example.com")
.WithScriptNonce("secure-nonce-123");
private Task HandleCspGenerated(CspHeader cspHeader)
{
// Apply CSP header to HTTP response
// HttpContext.Response.Headers.Add(cspHeader.HeaderName, cspHeader.HeaderValue);
return Task.CompletedTask;
}
}
Security Features
Sandbox Security Levels
| Level | Description | Use Case |
|---|---|---|
| None | No restrictions | Trusted content only |
| Basic | Scripts + same-origin | Most trusted widgets |
| Permissive | + forms + popups | Interactive widgets |
| Strict | Scripts + same-origin only | Display widgets |
| Paranoid | Scripts only | Untrusted content |
Message Validation
All iframe messages are automatically validated for:
- Origin verification - Ensures messages come from allowed domains
- Content validation - JSON structure and size limits
- Security filtering - Blocks malicious patterns and script injection
- Custom validation - Extensible validation pipeline
Demo
Interactive Demo - Try different security configurations live
Requirements
- .NET 8.0 or later
- Blazor Server or Blazor WebAssembly
- Modern browser with ES6 modules support
Browser Support
- Chrome 91+
- Firefox 90+
- Safari 15+
- Edge 91+
Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- NuGet: BlazorFrame Package
License
This project is licensed under the MIT License.
Built with ❤️ for the Blazor community
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.16)
- Microsoft.Extensions.Logging.Abstractions (>= 8.0.16)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.3.0 | 1,142 | 8/27/2025 |
| 2.1.2 | 588 | 7/12/2025 |
| 2.1.1 | 137 | 7/12/2025 |
| 2.1.0 | 140 | 7/11/2025 |
| 2.0.0 | 161 | 7/10/2025 |
| 1.4.0 | 156 | 7/7/2025 |
| 1.3.0 | 162 | 7/7/2025 |
| 1.2.2 | 162 | 7/7/2025 |
| 1.2.1 | 160 | 7/7/2025 |
| 1.2.0 | 161 | 7/7/2025 |
| 1.1.2 | 165 | 7/7/2025 |
| 1.1.1 | 158 | 7/7/2025 |
| 1.1.0 | 128 | 7/4/2025 |
| 1.0.1 | 127 | 7/4/2025 |
| 1.0.0 | 149 | 7/4/2025 |