Skip to content

fix: blazor <AbpStyles>/<AbpScripts> ignore PathBase#25336

Merged
EngincanV merged 2 commits intorel-10.2from
maliming/fix-blazor-pathbase-bundle-25335
Apr 29, 2026
Merged

fix: blazor <AbpStyles>/<AbpScripts> ignore PathBase#25336
EngincanV merged 2 commits intorel-10.2from
maliming/fix-blazor-pathbase-bundle-25335

Conversation

@maliming
Copy link
Copy Markdown
Member

@maliming maliming commented Apr 29, 2026

Resolves #25335

<AbpStyles> / <AbpScripts> emit bundle URLs with a leading /, which makes browsers ignore <base href> per RFC 3986 §5.2.2. Under a virtual application (IIS sub-app, reverse proxy that only forwards /foo/*), the PathBase is dropped and the request hits the origin root, returning 404.

Introduce IComponentBundleUrlBuilder (replaceable via DI) and inject NavigationManager so the components automatically prefix the bundle URL with the current PathBase, resolved from NavigationManager.BaseUri, when AppBasePath is not explicitly provided. The AppBasePath parameter from #22514 keeps working and takes precedence.

Copilot AI review requested due to automatic review settings April 29, 2026 06:26
@maliming maliming changed the base branch from rel-10.4 to rel-10.2 April 29, 2026 06:30
@maliming maliming added this to the 10.2-patch-final milestone Apr 29, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Blazor <AbpStyles> / <AbpScripts> bundle URLs ignoring PathBase under virtual applications by introducing a replaceable URL builder that derives a base path from NavigationManager.BaseUri when AppBasePath isn’t explicitly provided.

Changes:

  • Added IComponentBundleUrlBuilder + default ComponentBundleUrlBuilder to resolve bundle URLs with the current PathBase.
  • Updated <AbpStyles> and <AbpScripts> to resolve bundle file URLs via the new builder (still honoring AppBasePath precedence).
  • Added a new test project with unit tests for the URL builder and wired it into the solution.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Bundling/IComponentBundleUrlBuilder.cs Introduces an abstraction for building PathBase-aware bundle URLs.
framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Bundling/ComponentBundleUrlBuilder.cs Implements URL building logic using explicit AppBasePath or NavigationManager.BaseUri.
framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Bundling/AbpStyles.razor Uses the builder to emit PathBase-aware <link> URLs.
framework/src/Volo.Abp.AspNetCore.Components.Web.Theming/Bundling/AbpScripts.razor Uses the builder to emit PathBase-aware <script> URLs.
framework/test/Volo.Abp.AspNetCore.Components.Web.Theming.Tests/Volo/Abp/AspNetCore/Components/Web/Theming/Bundling/ComponentBundleUrlBuilder_Tests.cs Adds unit tests for ComponentBundleUrlBuilder.
framework/test/Volo.Abp.AspNetCore.Components.Web.Theming.Tests/Volo.Abp.AspNetCore.Components.Web.Theming.Tests.csproj Adds the new test project definition.
framework/test/Volo.Abp.AspNetCore.Components.Web.Theming.Tests/Volo.Abp.AspNetCore.Components.Web.Theming.Tests.abppkg Marks the new project as a test package (lib.test).
framework/Volo.Abp.slnx Registers the new test project in the solution.

- Skip prefixing for external URLs (http/https/protocol-relative/data:)
- Use IsNullOrWhiteSpace for AppBasePath check to align with PR #22514
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

@EngincanV EngincanV merged commit 0ed505d into rel-10.2 Apr 29, 2026
7 checks passed
@EngincanV EngincanV deleted the maliming/fix-blazor-pathbase-bundle-25335 branch April 29, 2026 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants