HangFire简单使用
作者:互联网
.NET 6简单使用HangFire
// Nuget
install-package Hangfire.AspNetCore
install-package Hangfire.SqlServer
1.appsettings.json添加连接字符串
"ConnectionStrings": {
"HangfireConnection": "server=.;database=HangfireTest;uid=sa;pwd=1234@qwer"
}
2.创建数据库
create database 数据库_name
go
3.Program注入服务和中间件
//Program.cs
// Add Hangfire services.
builder.Services.AddHangfire(configuration =>
configuration.UseSqlServerStorage(
builder.Configuration.GetConnectionString("HangfireConnection")));
// Add the processing server as IHostedService
builder.Services.AddHangfireServer();
// 启用HangFire面板
app.UseHangfireDashboard();
打开http://[ip]:[prot]/hangfire 就可以看到HangFire面板
数据库
标签:HangFire,builder,简单,Hangfire,Add,HangfireConnection,使用,数据库 来源: https://www.cnblogs.com/toyz9/p/16545676.html