[Route("/users/{id}", Matches = "ReturnFalse")]
public class AppRoute0Request {
public string partnerId { get; set; }
public string id { get; set; }
}
The ReturnFalse matcher is defined in the AppHost (Startup.cs)
public class AppHost : AppHostBase
{
...
// Configure your AppHost with the necessary configuration and dependencies your App needs
public override void Configure(Container container)
{
// enable server-side rendering, see: https://sharpscript.net/docs/sharp-pages
Plugins.Add(new SharpPagesFeature {
EnableSpaFallback = false
});
SetConfig(new HostConfig
{
AddRedirectParamsToQueryString = true,
DebugMode = AppSettings.Get(nameof(HostConfig.DebugMode), HostingEnvironment.IsDevelopment()),
});
Config.RequestRules.Add("ReturnFalse", req => {
Console.WriteLine("GOT HERE");
return false;
});
}
}
However, the route ends up going through anyways (ignoring that the rule returns false) and there is no log. Even when debugging, it doesn’t seem to hit the matcher function.
Upon closer inspection, the routes were returning html from wwwroot
public object Any(AppRoute2Request request) => Request.GetPageResult("/about.html");
and I serving the files directly from wwwroot has higher precedence than running the route. So the route with the URL param (the one that I originally posted) actually did run the matcher.
public object Any(AppRoute0Request request) => Request.GetPageResult("/users/[id].html");
Is there a way to not have the precedent be to serve the files from wwwroot first?