fix: blazor <AbpStyles>/<AbpScripts> ignore PathBase#25336
Merged
fix: blazor <AbpStyles>/<AbpScripts> ignore PathBase#25336
<AbpStyles>/<AbpScripts> ignore PathBase#25336Conversation
Contributor
There was a problem hiding this comment.
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+ defaultComponentBundleUrlBuilderto resolve bundle URLs with the currentPathBase. - Updated
<AbpStyles>and<AbpScripts>to resolve bundle file URLs via the new builder (still honoringAppBasePathprecedence). - 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
EngincanV
approved these changes
Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/*), thePathBaseis dropped and the request hits the origin root, returning 404.Introduce
IComponentBundleUrlBuilder(replaceable via DI) and injectNavigationManagerso the components automatically prefix the bundle URL with the currentPathBase, resolved fromNavigationManager.BaseUri, whenAppBasePathis not explicitly provided. TheAppBasePathparameter from #22514 keeps working and takes precedence.