0
I have a set of pages that all follow a similar pattern of /{report}/{id} but where {report} is replaced with a concrete name for each page. We also have a singleton reportManager that used to be updated in the page's OnParameterSet
protected override async Task OnParametersSetAsync(){ if (reportManager.SelectedId != id) { reportManager.SelectedId = id; } var item = reportManager.SelectedItem;}Instead of having to remember to put this on every new page is there a way to have this run for all the report pages
I have tried creating a component to wrap the pages, but since it i a component on the page, its OnParameterSet runs after the page's, so when the page loads reportManager.SelectedItem is not correctly set.
I have also thought about just creating a page for all the pages:
@page "/{reportName}/{id}"<div>@switch reportName { case "report1": <Report1 /> break; case "report2":<Report2 /> break; ...}</div>@ {[Parameter]public int Id { get; set; }[Parameter]public string ReportName { get; set; }protected override async Task OnParametersSetAsync(){ if (reportManager.SelectedId != id) { reportManager.SelectedId = id; } var item = reportManager.SelectedItem;}}But then this just requires that every time someone needs to remember to add the page here. Is there any way to just run this code for a set of paths?