I have an Owin Startup class that I am trying to use to setup a very basic Hangfire server.
This all works on my local when i run with F5.
[assembly: OwinStartup(typeof(Test.HangfireHostStartup))]
namespace Test
{
public class HangfireHostStartup
{
public void Configuration(IAppBuilder app)
{
File.AppendAllText(“c:/hangfire.txt”, “started”);
GlobalConfiguration.Configuration.UseSqlServerStorage();
app.UseHangfireDashboard();
app.UseHangfireServer();
}
}
}
When I try to publish this app to an IIS server, I can’t get it to start.
The app pool is in Integrated mode and using 4.0.
I have tried including owin:AutomaticAppStartup = “true” in my web.config.
The Microsoft.Owin.Host.SystemWeb dll is present in the bin directory of my deployed app.
Any ideas? I am completely stuck.
Try by removing Owin class and use Global.asax file.
using Hangfire;
using System;
namespace SampleHangFire
{
public class Global : System.Web.HttpApplication
{
private BackgroundJobServer _backgroundJobServer;
protected void Application_Start(object sender, EventArgs e)
{
GlobalConfiguration.Configuration.UseSqlServerStorage("<hangfire connection string>");
_backgroundJobServer = new BackgroundJobServer();
}
protected void Application_End(object sender, EventArgs e)
{
_backgroundJobServer.Dispose();
}
}
}
This should work.
If any issue please share it.
This didn’t appear to work.
I published this to the server and then stood up the dashboard on my localhost. When I went to the Hangfire servers tab, the only Hangfire server it showed was my local.
Well if code work on Local and having only issue when you publish then there might be something wrong during Publish…
Check log/trace for publishing Website.