[英]Hangfire Implementation with MVC Asp.net core
我有一個在應用程序內部實現hangfire儀表板的要求。我的主頁上有一個鏈接“儀表板”,單擊該Hangfire儀表板應作為應用程序的一部分打開。
我嘗試的以下代碼
單擊儀表盤鏈接
public void BuildNavigation(string name, NavigationBuilder builder)
{
if (!String.Equals(name, "menu", StringComparison.OrdinalIgnoreCase))
{
return;
}
builder
.Add(T["Dashboard"], "1", installed => installed.Action("Index", "HangfireDashboard", "Modules.HangfireDashboard"));
}
Startup.cs
public class Startup : StartupBase
{
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IServiceProvider serviceProvider)
{
app.UseMvc(routes =>
{
routes.MapRoute(name: "default", template: "{controller=HangfireDashboard}/{action=Index}/{id?}");
});
app.UseHangfireServer(options: new BackgroundJobServerOptions()
{
Activator = new JobActivator()
});
app.UseHangfireDashboard("/TestPage");
}
public override void ConfigureServices(IServiceCollection services)
{
services.AddHangfire(configuration => configuration.UseSqlServerStorage(TenenatDbConfigurationProvider.GetDefaultConnectionString()));
services.AddScoped<INavigationProvider, ModulesMenu>();
}
}
這是在打開模塊索引頁面而不是hangfire儀表板。
讓我知道是否有人在您的模塊中實現了此功能
謝謝
開發
不知道我是否正確-但據我所知,您正嘗試通過鏈接訪問hangfire儀表板。
正如Dilhan所說,默認路由是[您的站點] / hangfire,但是當您為app.UseHangfireDashboard("/TestPage")
給出了一個字符串參數時,分配的字符串就是您的新路由。 因此,如果要訪問hangfire儀表板,則需要引用[您的站點] / TestPage。
希望有幫助:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.