【问题标题】:Hangfire Implementation with MVC Asp.net core使用 MVC Asp.net 核心实现 Hangfire
【发布时间】:2017-03-24 05:43:24
【问题描述】:

我需要在我的应用程序中实现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仪表板。

如果有人在你的模块中实现了这个,请告诉我

谢谢

开发

【问题讨论】:

  • 不确定 ASP.NET Core。但是在我的 ASP.NET WebAPI 项目中,我可以访问像 myapp/hangfire 这样的仪表板,而无需任何额外的配置(默认情况下它会添加路由)
  • 为什么这个标签是'果园'?
  • 我们也在使用 Orchard 框架

标签: c# asp.net-core-mvc orchardcms hangfire


【解决方案1】:

不知道我是否正确 - 但据我了解,您正试图通过链接访问 hangfire 仪表板。

正如 Dilhan 已经评论的那样,默认路由是 [您的站点]/hangfire,但是当您将字符串参数提供给 app.UseHangfireDashboard("/TestPage") 时,分配的字符串是您的新路由。因此,如果您想访问hangfire-dashboard,您需要参考[您的站点]/TestPage..

希望有帮助:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-14
    • 2020-08-16
    • 1970-01-01
    • 2021-12-31
    相关资源
    最近更新 更多