diff --git a/plugins/dotnet11/skills/aspnetcore-blazor-components-net11/SKILL.md b/plugins/dotnet11/skills/aspnetcore-blazor-components-net11/SKILL.md new file mode 100644 index 0000000000..562e287e4d --- /dev/null +++ b/plugins/dotnet11/skills/aspnetcore-blazor-components-net11/SKILL.md @@ -0,0 +1,307 @@ +--- +name: aspnetcore-blazor-components-net11 +description: > + Covers new .NET 11 APIs across Microsoft.AspNetCore.Components, + Components.Web, and Components.Endpoints. Includes navigation improvements + (GetUriWithHash, RelativeToCurrentUri), contravariant RenderFragment, + IComponentPropertyActivator, form components (Label, DisplayName), media + components (Image, Video, FileDownload with MediaSource), EnvironmentBoundary, + BasePath, ITempData, and TempDataProviderType. Use when building Blazor apps + that need navigation, forms, media rendering, environment-conditional content, + or cross-request temporary data in .NET 11. +license: MIT +--- + +# ASP.NET Core Blazor Components — .NET 11 APIs + +Target framework: `net11.0` + +--- + +## Navigation Improvements +Assembly: `Microsoft.AspNetCore.Components` + +### GetUriWithHash + +Extension method returning the current URI with a hash fragment appended. + +```csharp +public static string GetUriWithHash(this NavigationManager nav, string hash); +``` + +```razor +@inject NavigationManager Nav + + + +@code { + private void GoToSection() + { + string uri = Nav.GetUriWithHash("#section1"); + Nav.NavigateTo(uri); + } +} +``` + +### NavigationOptions.RelativeToCurrentUri + +New `bool` init-only property. When `true`, the target URI resolves relative +to the current URI rather than the base URI. + +```razor +@inject NavigationManager Nav + +@code { + private void GoToSettings() + { + // From /app/dashboard → /app/settings + Nav.NavigateTo("../settings", new NavigationOptions + { + RelativeToCurrentUri = true + }); + } +} +``` + +### NavLink.RelativeToCurrentUri + +| Type | Default | Description | +|------|---------|-------------| +| `bool` | `false` | When `true`, matching is relative to current URI | + +```razor + + Profile Settings + +``` + +--- + +## Component Model +Assembly: `Microsoft.AspNetCore.Components` + +### IComponentPropertyActivator + +Interface for custom component property activation. + +```csharp +public interface IComponentPropertyActivator +{ + Action GetActivator(Type type); +} +``` + +### Contravariant RenderFragment<in TValue> + +`RenderFragment` now uses `in` variance, enabling assignment +compatibility with more derived types. + +```csharp +RenderFragment animalFragment = (animal) => builder => +{ + builder.AddContent(0, $"Animal: {animal.Name}"); +}; + +// Valid due to contravariance +RenderFragment dogFragment = animalFragment; +``` + +--- + +## Form Components +Assembly: `Microsoft.AspNetCore.Components.Web` + +### Label<TValue> + +Renders `