Servicestack FallbackRoute does not recognize trailing slash
So the ServiceStack FallbackRoute in my code [FallbackRoute ("/ {Path *} /")], which is the setup that the ServiceStack documentation says, will handle every unmatched route.
If a route is given, such as example.com/api, it will respond correctly to the fallback response.
However, if given example.com/api/, then it simply returns an empty 200 OK response.
It handles unmatched routes with content after the slash correctly, so example.com/api/arglkjadkf will be sent to fallback
I want Servicestack to be able to take the url with a trailing slash after the base path and hit the fallback path.
source to share
ServiceStack does not distinguish trailing slashes as different routes, i.e.
[Route("/api")]
Handles both /api
, and so/api/
This way, there should be no trailing slashes in the route definition, and since you are using a wildcard, that is:
[FallbackRoute("/{PathInfo*}")]
public class FallbackForUnmatchedRoutes
{
public string PathInfo { get; set; }
}
This will handle any routes of any depth that have not yet been processed.
source to share