Skip to content

Revert Request.Path when using SiteRouting and no route is found#2099

Open
Einarsson wants to merge 1 commit intoPiranhaCMS:masterfrom
Einarsson:siterouting-reset-path-if-no-route-found
Open

Revert Request.Path when using SiteRouting and no route is found#2099
Einarsson wants to merge 1 commit intoPiranhaCMS:masterfrom
Einarsson:siterouting-reset-path-if-no-route-found

Conversation

@Einarsson
Copy link
Copy Markdown

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.

@Einarsson
Copy link
Copy Markdown
Author

@dotnet-policy-service agree

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.

1 participant