Skip to content

API Proposal: BasePath component for Blazor #66388

Closed

Description

@javiercn

Background and Motivation

Blazor apps hosted under subpaths (e.g., /dashboard) require a <base href=""> element with the correct path. This currently requires manual editing or per-app JavaScript workarounds, which are inconsistent across hosting models and easy to break during deployment. The BasePath component centralizes how Blazor apps compute their base URI by rendering a <base> element whose href value matches the current request path base.

Source: PR #64590, fixes #6818.

Proposed API

namespace Microsoft.AspNetCore.Components.Endpoints;

+ public sealed class BasePath : IComponent
+ {
+ }

Note: BasePath has no public parameters; it renders based on NavigationManager.BaseUri at runtime.

Usage Examples

@using Microsoft.AspNetCore.Components.Endpoints

<head>
    <BasePath />
    <link href="app.css" rel="stylesheet" />
</head>

Replaces:

<base href="/" />

Alternative Designs

Manual <base href=""> edits or per-app JavaScript. These workarounds were inconsistent across hosting models.

Risks

None — additive component. Existing <base href> usage continues to work unchanged.

Activity

  1. added
    area-blazor
    api-ready-for-review
    on Apr 20, 2026
  2. dotnet-policy-service commented on Apr 20, 2026

    @dotnet-policy-service
    Contributor

    Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:

    • The PR contains changes to the reference-assembly that describe the API change. Or, you have included a snippet of reference-assembly-style code that illustrates the API change.
    • The PR describes the impact to users, both positive (useful new APIs) and negative (breaking changes).
    • Someone is assigned to "champion" this change in the meeting, and they understand the impact and design of the change.
  3. github-actions commented on Apr 20, 2026

    @github-actions
    Contributor

    Triage Summary

    Area: area-blazor (proposal adds a new BasePath Razor component in Microsoft.AspNetCore.Components.Endpoints, directly in the Blazor/Components space)
    Type: api-proposal (formal API addition proposal for a new sealed BasePath : IComponent class; additive, no breaking changes)

    Potential Duplicates

    Notes

    • The issue is filed by a team member (@javiercn) and is already marked api-ready-for-review, indicating it has been through internal review. Added api-proposal to complete type classification.
    • No parameters are exposed on the component; it derives the <base href> from NavigationManager.BaseUri, keeping the API surface minimal.
    • Additive only — existing manual <base> tags remain fully supported.

    Generated by Issue Triage Agent for dotnet/aspnetcore for issue #66388 · ● 169.5K · ◷

  4. added this to the 11.0-preview5 milestone on Apr 23, 2026
  5. added
    api-approved
    and removed
    api-ready-for-review
    on Jun 1, 2026
  6. javiercn commented on Jun 1, 2026

    @javiercn
    MemberAuthor

    Proposed API

    namespace Microsoft.AspNetCore.Components.Endpoints;
    
    + public sealed class BasePath : IComponent
    + {
    + }

    Approved without changes

  7. self-assigned this
    on Jun 5, 2026
  8. modified the milestones: 11.0-preview7, 11.0.0 on Jul 22, 2026
  9. javiercn commented on Jul 27, 2026

    @javiercn
    MemberAuthor

    Done. Microsoft.AspNetCore.Components.Endpoints.BasePath shipped as approved in c8d47d3. Closing as implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api-approvedarea-blazor

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions