不能使用Hangfire与ASP。净webforms网站

时间:2021-11-11 07:42:06

I have created empty asp.net webforms website using Visual studio 2013 from File > new > Website (not project ) and installed Hangfire library. then i have added Startup.cs File in App_code and root folder. then i have created simple test in Global.ascx file

我使用Visual studio 2013从文件>新建的>网站(不是项目)创建了空的asp.net webforms网站,并安装了Hangfire库。然后我添加了Startup。在App_code和根文件夹中的cs文件。然后我在全球创建了简单的测试。ascx文件

void Application_Start(object sender, EventArgs e) 
    {

        Hangfire.RecurringJob.AddOrUpdate(() => Console.WriteLine("I am done!"), Hangfire.Cron.Minutely);

    } 

when i try to run the website, it returns

当我尝试运行网站时,它会返回。

JobStorage.Current property value has not been initialized. You must set it before using Hangfire Client or Server API.

but if i create a project and do the same steps, it runs without any problem, anyone can help ?

但是,如果我创建一个项目并执行相同的步骤,那么它运行起来没有任何问题,谁能提供帮助?

2 个解决方案

#1


3  

I moved this line

我搬到这条线

Hangfire.RecurringJob.AddOrUpdate(() => Console.WriteLine("I am done, wasim!"), Hangfire.Cron.Minutely);

from Application_Start, i think he was calling it early, so i moved it to .aspx page.. and everything works well now!

从Application_Start开始,我认为他调用得比较早,所以我将它移动到。aspx页面。现在一切都很顺利!

#2


0  

hello i have you some problem

你好,我有问题要问你

so. you must remove this config

所以。您必须删除此配置

   <add key="owin:AppStartup" value="false" />

<add key="owin:AutomaticAppStartup" value="false" />

#1


3  

I moved this line

我搬到这条线

Hangfire.RecurringJob.AddOrUpdate(() => Console.WriteLine("I am done, wasim!"), Hangfire.Cron.Minutely);

from Application_Start, i think he was calling it early, so i moved it to .aspx page.. and everything works well now!

从Application_Start开始,我认为他调用得比较早,所以我将它移动到。aspx页面。现在一切都很顺利!

#2


0  

hello i have you some problem

你好,我有问题要问你

so. you must remove this config

所以。您必须删除此配置

   <add key="owin:AppStartup" value="false" />

<add key="owin:AutomaticAppStartup" value="false" />