I’ve been trying to get the active menu working in a partial template but it appears that the PathInfo is not being found correctly.
I was wondering if I might be doing something wrong.
The setup is a netcore console app, using kestrel and the apphost has the TemplatePagesFeature
plugin registered.
I have a service with the following
public class ViewService : Service
{
public object Any(ViewIndex request) => new PageResult(Request.GetPage("/index"));
public object Any(ViewLogs request) => new PageResult(Request.GetPage("/logs"));
...
}
[Route("/index")]
// [Route("/")] throws route is invalid exception
public class ViewIndex { }
[Route("/logs")]
public class ViewLogs { }
I have the following four files
\wwwroot\_layout.html
\wwwroot\menu.html
\wwwroot\index.html
\wwwroot\logs.html
the menu partial is bascially identical to the example but with the links collection altered. the layout is again much like the examples with the
the partial defined.
``{{ ‘menu’ | partial }}```
and the {{ body }}
which is rendering the pages ok.
The index and log pages are bascially empty except for a title.
Firstly, when launching the project, the index.html page is rendered fine and route ‘’ is matched with the ‘active’ class being rendered.
However, it is not hitting the ViewService.Any(ViewIndex request)
method.
How can I get default the root path to use the service method?
If I type the /index url in, the method is hit, but the route is not matched.
If I navigate to the /logs url, again the service method is hit, but the route is not matched.
I have more pages and the behaviour is the same, when calling the service methods, the matchesPathInfo
in the menu partial is unable to get the PathInfo from the request which is why regardless of the path being checked, it is not able to match.
Any suggestions as to what I can try to figure where the problem lies?