I have created a HangFire job in my ASP.NET MVC application that has some specific error scenarios. When these scenarios happen I want the HangFire job to fail, so I’m throwing these exceptions and letting HangFire log them through NLog. The logging part works perfectly without configuring anything additional, but the HangFire jobs always get marked as Success. What am I doing wrong here? I’ve followed all the tutorials and configure HangFire as follows:
` private void ConfigureHangfire(IAppBuilder app)
{
var dashOptions = new DashboardOptions
{
AuthorizationFilters = new[] { new HangFireAuthorizationFilter() }
};
var serverOptions = new SqlServerStorageOptions
{
PrepareSchemaIfNecessary = false,
};
GlobalConfiguration.Configuration
.UseSqlServerStorage(ConfigurationManager.ConnectionStrings["PortalContext"].ToString(), serverOptions);
JobStorage.Current = new SqlServerStorage(ConfigurationManager.ConnectionStrings["PortalContext"].ToString());
app.UseHangfireServer();
app.UseHangfireDashboard("/networkStats", dashOptions);
}`