I am using hangfire in mvc application. I am sending reminder to user for his/her appointment. I have installed hangfire in my app. I have configured hangfire in startup.cs class. But when i run the app, it produce the below error, JobStorage. Current property value has not been initialized. You must set it before using Hangfire Client or Server API.
using Hangfire;
using Hangfire.SqlServer;
using Microsoft.Owin;
using Owin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using UKC.Data.Infrastructure;
using UKC.UI.Helper;
[assembly: OwinStartup(typeof(UKC.UI.App_Start.Startup))]
namespace UKC.UI.App_Start
{
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
GlobalConfiguration.Configuration
.UseSqlServerStorage("DbEntities");
app.UseHangfireDashboard();
app.UseHangfireServer();
}
}
}
public static void InitializeHangFire()
{
var sqlStorage = new SqlServerStorage("connectionString");
var options = new BackgroundJobServerOptions
{
ServerName = "Test Server"
};
JobStorage.Current = sqlStorage;
}