Documenting aspnetcore hosting gap analysis progress - #838
Merged
AndreaCuneo merged 2 commits intoAug 4, 2026
Merged
Conversation
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Co-authored-by: AndreaCuneo <5227688+AndreaCuneo@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
AndreaCuneo
August 4, 2026 17:21
View session
AndreaCuneo
approved these changes
Aug 4, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds strict X-Forwarded-Prefix handling to the Minimal API host pipeline (with an application opt-out) and documents the new behavior as part of the ASP.NET Core hosting gap-analysis progress.
Changes:
- Add
ArkMinimalApiHostOptions.UseForwardedPrefix(defaulttrue) and middleware that validatesX-Forwarded-Prefix, rejecting malformed/ambiguous values with HTTP 400. - Add sample integration tests covering valid/invalid/multiple
X-Forwarded-Prefixheader scenarios. - Update mediator framework docs and task tracking to reflect the new forwarded-prefix validation behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/aspnetcore/Ark.Tools.AspNetCore.MinimalApi/ArkMinimalApiHostExtensions.cs | Introduces forwarded-prefix option + request middleware that validates and applies X-Forwarded-Prefix to PathBase. |
| samples/Ark.MediatorFramework.Sample/test/Ark.MediatorFramework.Sample.Tests/ForwardedPrefixTests.cs | Adds integration tests verifying 200 for a valid prefix and 400 for invalid/multiple prefixes. |
| docs/mediator-framework/progress/tasks/aspnetcore/HST-03-path-base-validation.md | Marks the forwarded-prefix validation acceptance items as completed. |
| docs/mediator-framework/guide/host-setup-and-composition.md | Documents forwarded-prefix validation in host setup and middleware ordering guidance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
AndreaCuneo
approved these changes
Aug 4, 2026
AndreaCuneo
deleted the
copilot/docsmediator-frameworkprogressaspnetcore-hosting-g
branch
August 4, 2026 17:35
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.
This pull request introduces strict validation and support for the
X-Forwarded-Prefixheader in the Minimal API host, ensuring that path base forwarding is secure and predictable. It adds an option to enable or disable this feature, updates documentation to reflect the new behavior, and provides comprehensive tests to verify correct handling of valid, invalid, and ambiguous prefixes.Forwarded Prefix Handling and Validation
UseForwardedPrefixoption toArkMinimalApiHostOptions(default:true), allowing the host to accept and strictly validate theX-Forwarded-Prefixheader. If enabled, a valid prefix is prepended toPathBase, while malformed or ambiguous values result in a400 Bad Requestbefore downstream middleware runs. A private method,TryGetForwardedPrefix, implements the validation logic. ([[1]](https://github.com/ARKlab/Ark.Tools/pull/838/files#diff-17beb4389c729323e36094919ca76aae4e89b338da7a3af5b883a5b3f835b8e9R37-R41),[[2]](https://github.com/ARKlab/Ark.Tools/pull/838/files#diff-17beb4389c729323e36094919ca76aae4e89b338da7a3af5b883a5b3f835b8e9R113-R133),[[3]](https://github.com/ARKlab/Ark.Tools/pull/838/files#diff-17beb4389c729323e36094919ca76aae4e89b338da7a3af5b883a5b3f835b8e9R152-R211))Documentation Updates
UseForwardedPrefixoption, describe the validation process, and clarify the order of middleware execution. The documentation now explains how invalid or ambiguousX-Forwarded-Prefixvalues are handled and how to disable the feature if handled externally. ([[1]](https://github.com/ARKlab/Ark.Tools/pull/838/files#diff-5c75e2f737b7656e9b1177be1b75d861f5bea87ddde3c539dbf5d94f90a4a9a8R142),[[2]](https://github.com/ARKlab/Ark.Tools/pull/838/files#diff-5c75e2f737b7656e9b1177be1b75d861f5bea87ddde3c539dbf5d94f90a4a9a8L173-R174),[[3]](https://github.com/ARKlab/Ark.Tools/pull/838/files#diff-5c75e2f737b7656e9b1177be1b75d861f5bea87ddde3c539dbf5d94f90a4a9a8L192-R196))Testing
ForwardedPrefixTeststo verify that valid prefixes are accepted, malformed prefixes are rejected, and multiple prefixes are treated as ambiguous and rejected with a400status. ([samples/Ark.MediatorFramework.Sample/test/Ark.MediatorFramework.Sample.Tests/ForwardedPrefixTests.csR1-R54](https://github.com/ARKlab/Ark.Tools/pull/838/files#diff-0ebd5a9647b64f9062ff6f623f21f897166caa26b9aec9227c9ad64202d0ad3cR1-R54))[docs/mediator-framework/progress/tasks/aspnetcore/HST-03-path-base-validation.mdL33-R37](https://github.com/ARKlab/Ark.Tools/pull/838/files#diff-3a23c981c679cc2d08d43aad13e539de26f887dd5c5604bc03ad56ce0b23fb5dL33-R37))Pull request created by AI Agent