## Executive Summary

Daniel Roth showcases the evolutionary advancements in **ASP.NET Core** and **Blazor** in **.NET 11**, organized around three foundational pillars: **Performance**, **Security**, and **Productivity**:

1. **Hyperscale Performance:** Driven by Microsoft internal workloads (MSN, Edge, Bing, Teams). Features 29% lower GC pauses, smaller Blazor WebAssembly downloads, pausing idle Blazor Server circuits, and a Kestrel optimization that delivers **30% higher bad-request throughput** by eliminating exception propagation for malformed HTTP requests.
2. **Built-in Modern Security:**
   - **Automatic CSRF via Browser Fetch Metadata:** Protects cross-origin requests by default using `Sec-Fetch-Site` and `Sec-Fetch-Mode`, delivering **4x higher requests/sec** and **65% lower memory allocations** compared to traditional anti-forgery tokens.
   - **Authentication Refresh for Long-Lived Connections:** SignalR hubs and Blazor Server circuits re-authenticate existing connections using updated tokens/claims without reconnecting or losing unsaved form state.
3. **Productivity & Ecosystem:**
   - **C# 15 Unions in APIs & Web UI:** Native serialization via `System.Text.Json` without discriminators, combined with **OpenAPI 3.2 `anyOf` schema** generation.
   - **Asynchronous Validation:** `AsyncValidationAttribute`, `IAsyncValidatableObject`, and `EditContext.IsValidationPending` UI bindings for live validation spinners.
   - **Blazor Virtualize Upgrades:** Support for variable-height rows, scroll anchoring (`AnchorMode.Bottom`), and programmatic scrolling (`ScrollToItemAsync`).
   - **WebAssembly on Background Web Workers:** Offloads CPU-intensive operations off the browser UI thread to background web workers using dedicated Aspire client templates.
   - **Open Source Contributions:** Free MIT-licensed component suites from Infragistics (50+ Ignite UI components) and Syncfusion (Toolkit for Blazor), including official Roslyn analyzers.

---

## Detailed Section-by-Section Breakdown

### 1. Hyperscale Performance & Kestrel Bad-Request Optimization

**Presenter:** Daniel Roth

.NET powers core Microsoft services at massive scale:
- **MSN, Edge, and Windows Personalized Feeds:** Over tens of billions of monthly page views. Moving to the latest runtime yielded **29% lower P95 GC pauses**, **11% lower async plugin latency**, and **20% shorter thread pool queues**.
- **Blazor WebAssembly Improvements:** Trimmer enhancements yield smaller initial payload sizes, client-side caching for static server-side rendering (SSR), and automatic suspension of idle Blazor Server circuits to conserve server memory.

#### Kestrel Bad Request Optimization
Previously, Kestrel threw and caught exceptions upon encountering malformed HTTP requests, consuming significant CPU during denial-of-service or bot scans. In .NET 11:
- The HTTP parser returns structured error result codes.
- Responses are written directly from pre-allocated memory fragments.
- **Result:** Bad request throughput improves by **~30%**, freeing server CPU cycles for legitimate user traffic.

*Screenshot not supplied: Kestrel Bad Request Performance Optimization*

---

### 2. Automatic CSRF Protection via Browser Fetch Metadata

Traditional cross-site request forgery (CSRF) mitigation required generating, transmitting, and validating anti-forgery tokens (hidden input fields or request cookies).

.NET 11 introduces **Automatic CSRF Protection** leveraging browser **Fetch Metadata headers** (`Sec-Fetch-Site`, `Sec-Fetch-Mode`, `Sec-Fetch-Dest`):
- Enabled by default for all state-changing endpoints (POST, PUT, DELETE).
- Automatically blocks cross-site or cross-origin forged requests (e.g., from a malicious origin on another port or external domain) with a `400 Bad Request`.
- Allows same-origin requests immediately without requiring tokens.
- **Performance:** Handles **4x higher requests per second** with **65% fewer allocations** compared to anti-forgery token generation.

*Screenshot not supplied: Automatic CSRF Protection via Fetch Metadata*

---

### 3. Authentication Refresh for Long-Lived Connections (SignalR & Blazor Server)

Long-lived connections (such as SignalR WebSocket hubs and Blazor Server circuits) frequently outlive the authentication tokens used during connection negotiation, leading to stale permissions or unexpected disconnection.

In .NET 11:
- **SignalR Hub Token Refresh:** Hubs can accept updated credentials without closing the connection (`withAuthenticationRefresh` on JavaScript/.NET clients).
- **Blazor Server Integration:** The Blazor component hub automatically handles token refresh. When permissions or roles change (e.g. revoking refund authorization), the UI updates dynamically via `<AuthorizeView>` while preserving active user inputs and component state.

*Screenshot not supplied: SignalR and Blazor Authentication Refresh*

---

### 4. C# 15 Unions in Minimal APIs & System.Text.Json

ASP.NET Core in .NET 11 provides first-class support for C# 15 discriminated unions:

```csharp
app.MapGet("/returns/{id}/resolution", (int id) =>
    id % 2 == 0 
        ? (Resolution)new Refund(Amount: 89.99m) 
        : (Resolution)new Replacement(Model: "TB4-Pro"));
```

- **Clean Payloads:** `System.Text.Json` serializes only the active case without artificial wrapper objects or discriminator fields.
- **Razor / Blazor UI:** Components consume unions directly with exhaustive pattern matching switch expressions.

*Screenshot not supplied: C# 15 Unions in Minimal APIs*

---

### 5. OpenAPI 3.2 & `anyOf` Schema Generation

ASP.NET Core’s built-in OpenAPI document generator is updated to **OpenAPI 3.2**:
- Accurately generates `anyOf` schemas for C# 15 union return types.
- Client generators (and AI coding agents) understand the exact schema contracts for all possible return cases (`Refund` or `Replacement`).

*Screenshot not supplied: OpenAPI 3.2 Schema Generation for Unions*

---

### 6. Asynchronous Validation in Blazor & Minimal APIs

Real-world business validation often requires asynchronous calls (e.g., querying stock availability or checking account standing in a remote database).

.NET 11 introduces:
- **`AsyncValidationAttribute`:** A base class for custom async property validation attributes.
- **`IAsyncValidatableObject`:** For multi-field, object-level asynchronous validation.
- **Blazor UI Integration:** `EditContext.IsValidationPending` allows forms to display real-time loading spinners while validation queries complete.
- **Minimal API Parity:** The same async attributes validate incoming DTOs on backend endpoints.

```csharp
public class InStockAttribute : AsyncValidationAttribute
{
    protected override async Task<ValidationResult?> IsValidAsync(object? value, ValidationContext context, CancellationToken cancellationToken)
    {
        var inventory = context.GetRequiredService<IInventoryService>();
        bool inStock = await inventory.CheckStockAsync((string)value!, cancellationToken);
        return inStock ? ValidationResult.Success : new ValidationResult("Item out of stock.");
    }
}
```

*Screenshot not supplied: Asynchronous Validation with InStock Attribute and Spinner*

---

### 7. Blazor Virtualize Upgrades: Variable Heights & Scroll Anchoring

Rendering high-volume lists (10,000+ items) with the `<Virtualize>` component receives major enhancements in .NET 11:
- **Variable-Height Items:** Items can dynamically expand or contract without breaking virtual scroll bounds.
- **Scroll Anchoring:** Supports `AnchorMode.Bottom` or `AnchorMode.Top`. When users scroll to the bottom of an active feed, new incoming items automatically keep the viewport anchored to the latest message without jitter.
- **Programmatic Navigation:** The new `virtualizer.ScrollToItemAsync(index)` API enables instant jumping to any item across thousands of virtualized rows.

*Screenshot not supplied: Blazor Virtualize Component with Variable Height and Anchoring*

---

### 8. Razor Tooling & Developer Experience

Visual Studio and VS Code Razor tooling enhancements include:
- **Emmet Support:** Expanding HTML abbreviations (e.g. `ul>li*3` + Tab) directly in `.razor` files.
- **Remove & Sort Usings:** Cleaning unused `@using` directives across components.
- **`.editorconfig` Enforcement:** Formatting C# code blocks and curly brace alignment inside Razor files according to team rules.
- **Compact Asset Paths:** Clean `~/` path syntax for static assets instead of `@Assets["..."]`.

*Screenshot not supplied: Razor Tooling Emmet and EditorConfig Support*

---

### 9. Blazor WebAssembly + .NET Aspire & Background Web Workers

Daniel demonstrated full-stack cloud-native development combining Blazor WebAssembly with **.NET Aspire**:
- **Blazor Gateway:** A host component that bridges WebAssembly client apps with Aspire service discovery, configuration, and OpenTelemetry.
- **In-Browser Debugging:** Aspire dashboard provides a one-click **"Debug in Browser"** button to launch configured browser debugging sessions.
- **Background Web Workers:** High-compute CPU tasks (such as parsing hardware diagnostics bundles) can be dispatched to dedicated web workers, preventing UI freeze and maintaining 60 FPS responsiveness.
- **Open Source Ecosystem:** Showcased apps running free components from Infragistics Ignite UI (Grid Light) and Syncfusion Toolkit for Blazor (Charts).

*Screenshot not supplied: Blazor WebAssembly Running in Aspire Dashboard*
*Screenshot not supplied: Blazor Background Web Worker Offloading*
