Revert Request.Path when using SiteRouting and no route is found#2099
Open
Einarsson wants to merge 1 commit intoPiranhaCMS:masterfrom
Open
Revert Request.Path when using SiteRouting and no route is found#2099Einarsson wants to merge 1 commit intoPiranhaCMS:masterfrom
Einarsson wants to merge 1 commit intoPiranhaCMS:masterfrom
Conversation
Author
|
@dotnet-policy-service agree |
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.
Example:
You're using SiteRouting with a site defined under www.foo.com/en-us.
You also have controllers/endpoints under www.foo.com/en-us that isn't handled by Piranha. For example www.foo.com/en-us/bar.
When RoutingMiddleware gets the request it will find a matching site for www.foo.com/en-us/bar. It will then change the Request.Path to www.foo.com/bar. It will then proceed to try to find a Page in this site for the slug /bar. If it finds one, it will then add that Pages path to the route as intended.
However if it does not find a page. You would want Piranha to skip this request and pass it as-is to the underlying framework. But the path has been changed to www.foo.com/bar in a previous step when looking up the site.
In this case, I set the Request.Path back to the raw original path of the request, so that the request is skipped properly and forwarded to the underlying framework as www.foo.com/en-us/bar.