Sidio.Sitemap.Blazor
2.0.2
Prefix Reserved
dotnet add package Sidio.Sitemap.Blazor --version 2.0.2
NuGet\Install-Package Sidio.Sitemap.Blazor -Version 2.0.2
<PackageReference Include="Sidio.Sitemap.Blazor" Version="2.0.2" />
<PackageVersion Include="Sidio.Sitemap.Blazor" Version="2.0.2" />
<PackageReference Include="Sidio.Sitemap.Blazor" />
paket add Sidio.Sitemap.Blazor --version 2.0.2
#r "nuget: Sidio.Sitemap.Blazor, 2.0.2"
#:package Sidio.Sitemap.Blazor@2.0.2
#addin nuget:?package=Sidio.Sitemap.Blazor&version=2.0.2
#tool nuget:?package=Sidio.Sitemap.Blazor&version=2.0.2
Sidio.Sitemap.Blazor
Sidio.Sitemap.Blazor is a lightweight .NET library for generating sitemaps in Blazor server applications.
Versions
| Sidio.Sitemap.Core | Sidio.Sitemap.AspNetCore | Sidio.Sitemap.Blazor | |
|---|---|---|---|
| NuGet | |||
| Build | |||
| Coverage | |||
| Requirements | .NET Standard, .NET 8+, | .NET 8+, AspNetCore | .NET 8+, AspNetCore, Blazor server |
Installation
Add the package to your project.
Usage
Sitemap
Register services:
builder.Services
.AddHttpContextAccessor()
.AddDefaultSitemapServices<HttpContextBaseUrlProvider>();
Register the middleware. Make sure to choose the correct namespace.
using Sidio.Sitemap.Blazor;
app.UseSitemap();
Add the following attribute to your components (pages) to include them in the sitemap:
@* default *@
@attribute [Sitemap]
@* override route url *@
@attribute [Sitemap("/custom-url")]
@* add change frequency, priority and last modified date *@
@attribute [Sitemap(ChangeFrequency.Daily, 0.5, "2024-01-01")]
The sitemap is accessible at [domain]/sitemap.xml.
Providing additional nodes
You can provide additional sitemap nodes by implementing the ISitemapNodeProvider interface. The middleware will
detect and use your implementation automatically.
// Implement the ICustomSitemapNodeProvider interface
public class MyCustomSitemapNodeProvider : ICustomSitemapNodeProvider
{
public IEnumerable<SitemapNode> GetNodes()
{
return new List<SitemapNode> { new("/test") };
}
}
// Register the provider in DI
services.AddCustomSitemapNodeProvider<MyCustomSitemapNodeProvider>();
Security
The HttpContextBaseUrlProvider uses Request.Host which is not considered safe by default. To mitigate this, use one of the following approaches:
- Implement a custom
IBaseUrlProviderthat uses a safe way to determine the base URL, for example by usingIHttpContextAccessorand validating the host against a whitelist, or by loading a base URL from configuration. - Configure Forwarded Headers middleware:
app.UseForwardedHeaders(new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedHost | ForwardedHeaders.XForwardedProto,
KnownProxies = { IPAddress.Parse("IP_ADDRESS_OF_YOUR_PROXY") }
});
Upgrade to v2.x
In v2.x the reference to Sidio.Sitemap.AspNetCore is replaced by Sidio.Sitemap.Core. This reduces dependencies and makes the library
more lightweight.
Breaking changes:
- The
ICustomSitemapNodeProvidernow exists in namespaceSidio.Sitemap.Blazor. - References or using-statements to
Sidio.Sitemap.AspNetCorecan be removed.
FAQ
- Exception:
Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' while attempting to activate 'Sidio.Sitemap.Blazor.HttpContextBaseUrlProvider'.- Solution: call
services.AddHttpContextAccessor();to register theIHttpContextAccessor.
- Solution: call
- Build error (v1.x):
The call is ambiguous between the following methods or properties: 'Sidio.Sitemap.Blazor.ApplicationBuilderExtensions.UseSitemap(...)' and 'Sidio.Sitemap.AspNetCore.Middleware.ApplicationBuilderExtensions.UseSitemap(...)'- Solution: make sure to use the correct namespace:
using Sidio.Sitemap.Blazor;, and notusing Sidio.Sitemap.AspNetCore.Middleware;.
- Solution: make sure to use the correct namespace:
See also
| 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 is compatible. 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 is compatible. 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. |
-
net10.0
- Sidio.Sitemap.Core (>= 2.8.1)
-
net8.0
- Sidio.Sitemap.Core (>= 2.8.1)
-
net9.0
- Sidio.Sitemap.Core (>= 2.8.1)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Sidio.Sitemap.Blazor:
| Package | Downloads |
|---|---|
|
IdentitySuite.Documentations
IdentitySuite Documentations, a ready-to-use OpenId Connect Server based on Openiddict with Microsoft Identity and a comprehensive management shell. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated | |
|---|---|---|---|
| 2.0.2 | 413 | 4/15/2026 | |
| 2.0.1 | 471 | 2/12/2026 | |
| 2.0.0-preview | 148 | 1/10/2026 | |
| 1.3.0 | 1,453 | 1/7/2026 | |
| 1.2.0 | 1,017 | 11/12/2025 | |
| 1.1.3 | 1,583 | 5/26/2025 | |
| 1.1.2 | 417 | 4/22/2025 | |
| 1.1.1 | 615 | 1/27/2025 | |
| 1.1.0 | 354 | 11/13/2024 | |
| 1.0.6 | 336 | 11/11/2024 | |
| 1.0.5 | 393 | 10/14/2024 | |
| 1.0.4 | 424 | 7/31/2024 | |
| 1.0.3 | 297 | 7/12/2024 | |
| 1.0.2 | 327 | 6/16/2024 | |
| 1.0.1 | 311 | 5/19/2024 | |
| 1.0.0 | 304 | 5/19/2024 |