Http://localhost:50378/hangfire gives a 404 error for Web app in VS 2012

I just installed hangfire in my sample web application in VS 2012 using .Net 4.5.

It installed successfully and builds fine, but when I try to go to the dashboard it gives a 404 error. My web app URL for dashboard is: is http://localhost:50378/hangfire

I found the cause of my 404 dashboard problem. The Startup class needs to be correct, but the docs mention it incorrectly by showing a method called ‘Configuration’ as well as a method called ‘Configure’. Including both will result in 404 error. So please use the following code for Startup class ( replace MyWebApplication1 by your web app name). Another problem is that the namespaces (using Hangfire is listed in docs as using HangFire) are mentioned inaccurately in Startup class shown in the docs, which is an issue for newbies like me who are using this framework for the first time.

  

using Hangfire;
using Hangfire.SqlServer;
using Microsoft.Owin;
using Owin;



[assembly: OwinStartup(typeof(MyWebApplication1.Startup))]

namespace MyWebApplication1
{
    public class Startup
    {
        
        public void Configuration(IAppBuilder app)
        {
            app.UseHangfire(config =>
            {
                config.UseSqlServerStorage("TestingConnectionString1");
                config.UseServer();
            });
        }

    }
}

@sun21170, sorry for the delay, and thank you for hint about wrong documentation. I’ve already fixed it!

I’m having the same sort of problem… my project is vb rather than c# which might be important.
after installing via nuget, everything seems ok, but the dashboard url gives a 404, and I’ve found that the axd handler didn’t get added to the web.config file
enqueuing jobs works ok and the jobs show up in sql, so i think the startup.configuration method is ok

any clues on where to look next?

Can you paste your VB.Net code for ‘StartUp’ class?

It should correspond to what I had pasted in C#.

Maybe there is something missing or incorrect in that class.

here it is… it does seem to work though, as I can schedule jobs and they run, and records appear in the sql database

Imports Owin
Imports Hangfire
Imports Hangfire.SqlServer

Namespace Global
    Public Class Startup
        Public Sub Configuration(app As IAppBuilder)
            app.UseHangfire(Sub(config)
                                config.UseSqlServerStorage("DefaultConnection")
                                config.UseServer()
                            End Sub)
        End Sub
    End Class
End Namespace

vb.net projects in mvc have a different (flat) structure compared to their c# equivalents it seems

Try something like this

Imports Hangfire
Imports Hangfire.SqlServer
Imports Microsoft.Owin
Imports Owin



<Assembly: OwinStartup(GetType(Global.Startup))>

Namespace Global

        Public Class Startup
    
            Public Sub Configuration(app As IAppBuilder)
                app.UseHangfire(Function(config) 
                config.UseSqlServerStorage("DefaultConnection")
                config.UseServer()
    
    End Function)
            End Sub
    
        End Class
    End Namespace

aha! yes that works - not sure why or how though, because I just changed it back to which change exactly made it work, and it works with the old code now too… either way, it’s working now so I’m happy :smile:

May be a singleton pattern instantiated the class correctly when you switched to the new class definition. Then, when you switched back to old code, the code did not run since a single instance already existed.

This is my guess on why both code versions started working, but not sure if a singleton pattern is used with the Startup class.

I am new to Hangfire and trying to implement hangfire in out vb .net legacy code.

I am also getting 404 error for dashboard.

I am using below code in new startup.vb class file

Imports Hangfire
Imports Hangfire.SqlServer
Imports Microsoft.Owin
Imports Owin

<Assembly: OwinStartup(GetType(Global.Startup))>

Namespace Global

Public Class Startup

    Public Sub Configuration(app As IAppBuilder)
        GlobalConfiguration.Configuration.UseSqlServerStorage(ConfigurationManager.AppSettings("conString"))
        Dim options = New DashboardOptions With {.AppPath = VirtualPathUtility.ToAbsolute("~")}
        app.UseHangfireDashboard("/hangfire", options)
        app.UseHangfireServer()
    End Sub

End Class

End Namespace

Please let me know if I am missing something.