gpt4 book ai didi

asp.net-core - 如何在控制台应用程序中配置 hangfire 仪表板?

转载 作者:行者123 更新时间:2023-12-04 17:39:14 27 4
gpt4 key购买 nike

我正在使用 hangfire nuget 包来安排 asp.net 核心控制台应用程序中的作业

我尝试了所有将仪表板配置到控制台应用程序的方法

我如何从控制台应用程序托管网页???

我已经为仪表板配置创建了 startup.cs 类

using Hangfire;
using Microsoft.AspNetCore.Builder;

namespace PulsarHangFire
{
public class Startup
{
public void Configuration(IApplicationBuilder app)
{
app.UseHangfireDashboard("/hangfire");
app.UseHangfireServer();
}
}
}

谁能告诉我我该如何前进

最佳答案

创建一个 Startup.cs 文件(或从 .NET Core Web App 模板中获取一个文件)并配置以下内容:

public void ConfigureServices(IServiceCollection services)
{
// ... other required services ...

services.AddHangfire(configuration =>
{
// Do pretty much the same as you'd do with
// GlobalConfiguration.Configuration in classic .NET

// NOTE: logger and activator would be configured automatically,
// and in most cases you don't need to configure those.

configuration.UseSqlServerStorage(...);

// ... maybe something else, e.g. configuration.UseConsole()
});
}

最后添加 Hangfire 仪表板:

public void Configure(IApplicationBuilder app, IRecurringJobManager recurringJobManager)
{
// ... previous pipeline stages, e.g. app.UseAuthentication()

app.UseHangfireDashboard(...);

// ... next pipeline stages, e.g. app.UseMvc()

// then you may configure your recurring jobs here:
recurringJobManager.AddOrUpdate(...);
}

Source

关于asp.net-core - 如何在控制台应用程序中配置 hangfire 仪表板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55292866/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com