title: Can't access hangfire dashboard
body: <p>When I'm trying to access localhost:5000/hangfire I get redirected to error page(I have a controller which returns relative status pages(400,404 etc.)) </p>
  
  <p>This is the error I am getting:<a href="https://i.stack.imgur.com/eBbSN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eBbSN.png" alt="enter image description here"></a></p>
  
  <p>I suppose that /hangfire doesn't exist. The 'HandeErrorCode' it is referring to is from my controller.</p>
  
  <pre><code>[Route ("Error/{statusCode}")]
          public IActionResult HandleErrorCode (int statusCode) {
              var statusCodeData = 
  HttpContext.Features.Get&lt;IStatusCodeReExecuteFeature&gt; ();
  
          switch (statusCode) {
              case 404:
                  return View("Status404");
              case 401:
                  return View("Status401");
              case 400:
                  return View("Status400");    
              case 500:
                  return View("Status500");
          }
  
          return View ();
      }
  </code></pre>
  
  <p>Startup.cs </p>
  
  <p>ConfigureServices</p>
  
  <pre><code>services.AddHangfire(configuration=&gt;{
                configuration.UsePostgreSqlStorage(connectionString);
            }); 
  </code></pre>
  
  <p>Configure   </p>
  
  <pre><code>app.UseHangfireDashboard("/hangfire");    
        app.UseHangfireServer();
  </code></pre>
  
  <p>EDIT:
  Whole Startup.cs</p>
  
  <pre><code>public class Startup {
  public Startup (IHostingEnvironment env) {
  
    Console.WriteLine ("startin app {0}, which uses env {1} and has root {2}", env.ApplicationName, env.EnvironmentName, env.ContentRootPath);
    Configuration = new ConfigurationBuilder ()
      .SetBasePath (env.ContentRootPath)
      .AddJsonFile ("appsettings.json", optional : true, reloadOnChange : true)
      .AddJsonFile ($"appsettings.{env.EnvironmentName}.json", optional : true)
      .AddEnvironmentVariables ()
      .Build ();
  
    Console.WriteLine ("Current env variables are as follows: ");
    var enumerator = Environment.GetEnvironmentVariables ().GetEnumerator ();
    while (enumerator.MoveNext ()) {
      Console.WriteLine ($"{enumerator.Key,5}:{enumerator.Value,100}");
    }
  
  }
  
  public IConfigurationRoot Configuration { get; }
  
  // This method gets called by the runtime. Use this method to add services to the container.
  public void ConfigureServices (IServiceCollection services) {
  
    services.AddMvc ();
    // Add framework services.
    var connectionString = Configuration["ConnectionStrings:DefaultConnection"];
  
    Console.WriteLine ("using conn str: {0}", connectionString);
    services.AddEntityFrameworkNpgsql ()
      .AddDbContext&lt;EntityContext&gt; (
        options =&gt; options.UseNpgsql (connectionString)
  
      );
    services.AddIdentity&lt;User, Role&gt; (config =&gt; {
        config.SignIn.RequireConfirmedEmail = true;
      })
      .AddEntityFrameworkStores&lt;EntityContext&gt; ()
      .AddDefaultTokenProviders ();
  
    services.Configure&lt;IdentityOptions&gt; (options =&gt; {
      options.Password.RequireDigit = false;
      options.Password.RequiredLength = 5;
      options.Password.RequireLowercase = false;
      options.Password.RequireNonAlphanumeric = false;
      options.Password.RequireUppercase = false;
    });
  
    services.ConfigureApplicationCookie (options =&gt; options.LoginPath = "/account/login");
  
    services.AddAuthentication (CookieAuthenticationDefaults.AuthenticationScheme)
      .AddCookie (options =&gt; {
        options.LoginPath = "/Account/Login";
        options.LogoutPath = "/Account/Logout";
      });
  
    // SERVICE FILTERS
    services.AddScoped&lt;ActivePackageFilterAttribute, ActivePackageFilterAttribute&gt; ();
    services.AddScoped&lt;ActiveUserFilterAttribute, ActiveUserFilterAttribute&gt; ();
    services.AddSingleton&lt;AccountBilling, AccountBilling&gt; ();
  
    services.AddMemoryCache ();
  
    services.AddHangfire (configuration =&gt; {
      configuration.UsePostgreSqlStorage (connectionString);
    });
  
    services.AddMvc (config =&gt; {
        config.ModelBinderProviders.Insert (0, new InvariantDecimalModelBinderProvider ());
        //config.Filters.Add(typeof(RedirectActionFilter));
      })
      .SetCompatibilityVersion (CompatibilityVersion.Version_2_2)
      .AddJsonOptions (options =&gt; {
        options.SerializerSettings.ContractResolver = new DefaultContractResolver ();
        options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
      })
      .AddViewLocalization (LanguageViewLocationExpanderFormat.Suffix, opts =&gt; { opts.ResourcesPath = "Resources"; })
      .AddDataAnnotationsLocalization ();
  
    //services.AddScoped&lt;RedirectActionFilter&gt;();
    services.AddAutoMapper ();
  
    services.AddSingleton&lt;AutoMapper.IConfigurationProvider&gt; (Automapper.AutoMapperConfig.RegisterMappings ());
  
    //services.AddSingleton(Mapper.Configuration);
    services.AddScoped&lt;IMapper&gt; (sp =&gt; new Mapper (sp.GetRequiredService&lt;AutoMapper.IConfigurationProvider&gt; (), sp.GetService));
  
    services.AddDistributedMemoryCache (); // Adds a default in-memory implementation of IDistributedCache
    services.AddSession ();
    // Add application services.
    services.AddTransient&lt;IEmailSender, AuthMessageSender&gt; ();
    services.AddTransient&lt;ISmsSender, AuthMessageSender&gt; ();
  
    services.AddScoped&lt;IRepository, Repository&gt; ();
    services.AddScoped&lt;Context, Context&gt; ();
  
    services.AddScoped&lt;IAccountBilling, AccountBilling&gt; ();
  
    services.Configure&lt;AdministratorEmailAddress&gt; (Configuration);
    services.Configure&lt;AuthMessageSenderOptions&gt; (Configuration);
    services.Configure&lt;TBCPaymentOptions&gt; (Configuration);
    services.AddScoped&lt;ViewRender, ViewRender&gt; ();
    services.AddSingleton&lt;IHttpContextAccessor, HttpContextAccessor&gt; ();
    services.Configure&lt;RequestLocalizationOptions&gt; (opts =&gt; {
      var supportedCultures = new [] {
      new CultureInfo ("en"),
      new CultureInfo ("ka"),
      new CultureInfo ("ru")
      };
  
      opts.DefaultRequestCulture = new RequestCulture ("ka");
      // Formatting numbers, dates, etc.
      opts.SupportedCultures = supportedCultures;
      // UI strings that we have localized.
      opts.SupportedUICultures = supportedCultures;
    });
  
    // Add converter to DI
    //services.AddSingleton(typeof(IConverter), new BasicConverter(new PdfTools()));
    services.AddSingleton&lt;ITemplateService, TemplateService&gt; ();
    services.AddSingleton (typeof (IConverter), new SynchronizedConverter (new PdfTools ()));
    services.AddScoped&lt;MailComposer&gt; ();
  
  }
  
  // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  public void Configure (IApplicationBuilder app, IHostingEnvironment env) {
  
    if (env.IsDevelopment ()) {
      app.UseDeveloperExceptionPage ();
      app.UseDatabaseErrorPage ();
    } else {
      app.UseStatusCodePagesWithReExecute ("/Error/{0}");
    }
  
    app.UseStaticFiles ();
  
    app.UseAuthentication ();
  
    app.UseForwardedHeaders (new ForwardedHeadersOptions {
      ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
    });
  
    var options = app.ApplicationServices.GetService&lt;IOptions&lt;RequestLocalizationOptions&gt;&gt; ();
    app.UseRequestLocalization (options.Value);
  
    app.UseSession ();
  
    // app.UseHangfireDashboard ("/hangfire", new DashboardOptions {
    //   Authorization = new [] { new HangFireAuthorization () }
    // });
  
    app.UseHangfireDashboard ();
    app.UseHangfireServer ();
    RecurringJob.AddOrUpdate&lt;IAccountBilling&gt; (a =&gt; a.CheckUserPayment (), Cron.Minutely);
    RecurringJob.AddOrUpdate&lt;IAccountBilling&gt; ("CalculateUserCharge", a =&gt; a.CalculateUserCharge (DateTime.Today.AddDays (-1)), Cron.Daily (21, 00), TimeZoneInfo.Utc);
    //RecurringJob.AddOrUpdate&lt;IAccountBilling&gt;("CalculateUserCharge",a=&gt;a.CalculateUserCharge(DateTime.Today.AddDays(-1)),Cron.Minutely);
  
    app.UseMvc (routes =&gt; {
      routes.MapRoute (
        name: "default",
        template: "{controller=Home}/{action=Index}/{id?}");
    });
  }
  </code></pre>
  
  <p>}
      }</p>
  
  <p>HangfireAuthorization.cs </p>
  
  <pre><code>public class HangFireAuthorization: IDashboardAuthorizationFilter{
  
  public bool Authorize([NotNull] DashboardContext context)
  {
      return context.GetHttpContext().User.IsInRole("Administrator");
  }
  </code></pre>
  
  <p>}</p>
  
  <p>How do I access hangfire dashboard?</p>