Search code examples
asp.netiisowinhangfire

Hangfire.io Dashboard mapped to IIS Virtual Directory


I'm having trouble getting the Hangfire (1.5.8) dashboard to work inside of an IIS Virtual Directoy. Everything works beautifully in my dev environment where my application is simply mapped to the root of localhost. Our beta server, on the other hand, uses Virtual Directories to separate apps and app pools.

It's an ASP.Net MVC site using Hangfire with an OWIN Startup class. It gets deployed to http://beta-server/app-name/. When I attempt to access either http://beta-server/app-name/hangfire or http//beta-server/hangfire I get a 404 from IIS.

For the purposes of troubleshooting this, my IAuthenticationFilter simply returns true.

Here is my Startup.cs, pretty basic:

public class Startup
  {
    public void Configuration(IAppBuilder app)
    {
      // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888

      GlobalConfiguration.Configuration
        .UseSqlServerStorage(new DetectsEnvironment().GetEnvironment());

      app.UseHangfireDashboard("/hangfire", new DashboardOptions
      {
        AuthorizationFilters = new[] {new AuthenticationFilter()}
      });
      app.UseHangfireServer();

    }
  }

Does anyone have a working implementation that gets deployed to a Virtual Directory? Are there any OWIN middleware admin/management tools I can use to dig into what URL is getting registered within IIS?


Solution

  • I ended up fixing this simply by adding the HTTPHandler to the section in web.config.

    <system.webServer>
    <handlers>
    <add name="hangfireDashboard" path="hangfire" type="System.Web.DefaultHttpHandler" verb="*" />
    </handlers>
    </system.webServer>