繁体   English   中英

使用MVC Asp.net核心执行Hangfire

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM