JobStorage.Current属性值尚未初始化.您必须先设置它,然后才能使用Hangfire客户端或服务器API [英] JobStorage.Current property value has not been initialized. You must set it before using Hangfire Client or Server API

查看:1402
本文介绍了JobStorage.Current属性值尚未初始化.您必须先设置它,然后才能使用Hangfire客户端或服务器API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在MVC应用程序中使用hangfire.我正在向用户发送提醒给他/她 预约.我已经在我的应用程序中安装了hangfire.我已经在配置了hangfire startup.cs类.但是当我运行该应用程序时,它会产生以下错误, JobStorage.当前属性值尚未初始化.您必须先设置它,然后才能使用Hangfire客户端或服务器API.

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();

        }
    }
}

推荐答案

用于在Asp.net核心中初始化

public static void InitializeHangFire()
        {
            var sqlStorage = new SqlServerStorage("connectionString");
            var options = new BackgroundJobServerOptions
            {
                ServerName = "Test Server"
            };
            JobStorage.Current = sqlStorage;
        }

这篇关于JobStorage.Current属性值尚未初始化.您必须先设置它,然后才能使用Hangfire客户端或服务器API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆