How to add more page in Dashboard?
How to add more page in Dashboard?
following
In short, you should do the following steps:
- Install the RazorGenerator extension for Visual Studio (here is GitHub repo).
- Create a
.cshtmlfile with the following content. You can see more examples in the Hangfire repository.
@* Generator: Template TypeVisibility: Internal GeneratePrettyNames: true *@
@inherits RazorPage
@* The rest of a page *@
- Set the
CustomToolproperty of a.cshtmlfile toRazorGenerator. After this step, a new class will appear in your project. - Register page for a route for a new class:
using Hangfire.Dashboard;
RouteCollection.Routes.AddRazorPage("/batches/started", x => new StartedBatchesPage());
- Add a new navigation menu item:
NavigationMenu.Items.Add(page => new MenuItem("Batches", page.Url.To("/batches/started")));
Register page for a route
any class is ok? when call this class?
Set the CustomTool property of a .cshtml file to RazorGenerator. After this step, a new class will appear in your project.
You should use class created by RazorGenerator.
You may also need to override its namespace.
@* Generator: Template
TypeVisibility: Internal
GeneratePrettyNames: true
Namespace: Hangfire.Dashboard.Pages
*@
@odinserj I couldn't find any extension or way to add a route
RouteCollection.Routes.AddRazorPage("/batches/started", x => new StartedBatchesPage());
Should it be DashboardRoutes.Routes ?
@odinserj the razor template generator isn't available for VS2022, is that the only way to extend or replace pages?