Dashboard Auth for VB.Net

I’m trying to get basic dashboard authorization working in my MVC VB.Net app. I just want to be able to add one user “admin” and a basic password “123”. I’ve tried various methods from here and nothing has worked so far (using 1.6.6):

Dim options As New DashboardOptions
options.Authorization = New IDashboardAuthorizationFilter() {
New AuthorizationFilter With {.Users = “some_user”, .Roles = “some_role”}
}

app.UseHangfireDashboard(“/hangfire”, options)
app.UseHangfireServer()

Whenever I try to run this I get:

Unable to cast object of type ‘Hangfire.Dashboard.AuthorizationFilter’ to type ‘Hangfire.Dashboard.IDashboardAuthorizationFilter’.

1 Like

+1 same issue here as far.

This is probably really bad form - but this is how I got it to work in VB.net. I ended up breaking apart the sections.

Dim user1 = New BasicAuthAuthorizationUser With {.Login = "admin", .PasswordClear = "mysupersecretpassword"}
Dim userList As New List(Of BasicAuthAuthorizationUser)
userList.Add(user1)

filterOptions.Users = userList

Dim filter = New BasicAuthAuthorizationFilter(filterOptions)
Dim filters As New List(Of BasicAuthAuthorizationFilter)
filters.Add(filter)

Dim options = New DashboardOptions() With {.AuthorizationFilters = filters.AsEnumerable}

app.UseHangfireDashboard("/hangfire", options)
GlobalConfiguration.Configuration.UseConsole()

What will be type of filterOptions ?

Dim filterOptions = New BasicAuthAuthorizationFilterOptions