Use dashboard in Self-Hosted OWIN Console Application


#1

Hi
How can I use dashboard in Self-Hosted OWIN Console Application ?

I started with this

using (WebApp.Start<Startup>("http://localhost:8888"))
        {
            Console.WriteLine("Server started... press ENTER to shut down");
            Console.ReadLine();
        }

and this is my configuration

public void Configuration(IAppBuilder app)
    {

        app.UseWelcomePage();

        var options = new SqlServerStorageOptions
        {
            PrepareSchemaIfNecessary = false,
            QueuePollInterval = TimeSpan.FromSeconds(15) // Default value

        };
        
        
        app.UseHangfire(config =>
        {
            config.UseSqlServerStorage(conn, options);
            config.UseServer();
            
        });


        
        app.UseHangfireDashboard("/hangfire", new DashboardOptions
        {
            AuthorizationFilters = new[]{new CustomAuthorization()},
            AppPath = "http://localhost:8888/hangfire" 
        
        });
    }

any help would be appreciated.


#2

Looks like you are using Hangfire 1.4.0. Then use the following configuration class:

public void Configuration(IAppBuilder app)
{
    app.UseWelcomePage();

    GlobalConfiguration.Configuration
        .UseSqlServerStorage(new SqlServerStorageOptions { PrepareSchemaIfNecessary = false });
        
    app.UseHangfireServer();
    app.UseHangfireDashboard("/hangfire", new DashboardOptions
    {
        AuthorizationFilters = new[]{ new CustomAuthorization() },
    });
}

#4

Hi

this is the sample that I’ve worked, the welcome page will be displayed but it doesn’t show dashboard . can you see where the problem is ?

by the way, I use 1.4.1


#5

What URL are you using? http://localhost:8888/hangfire should work fine.


#6

yes I use http://localhost:8888/hangfire . but it doesn’t work .

Did the sample work for you with above URL?


#7

I couldn’t come up with a solution and the sample didn’t work for me but as a trick, is it possible to use hangfire dashboard in an asp.net mvc app which doesn’t use this line //app.UseHangfireServer(); as below ? to be able to use just hangfire dashboard and not the hangfire servers to handle the tasks

    public void Configuration(IAppBuilder app)
    {

        GlobalConfiguration.Configuration
            .UseSqlServerStorage(conn, new SqlServerStorageOptions {PrepareSchemaIfNecessary = false});

        //app.UseHangfireServer();
        app.UseHangfireDashboard("/hangfire");

    }

and then use the below code , in another app as a windows service or a console app . Actually I want to use mvc just to provide dashboard and console app or windows service just to handle the tasks .

public void Configuration(IAppBuilder app)
    {

        GlobalConfiguration.Configuration
            .UseSqlServerStorage(conn, new SqlServerStorageOptions {PrepareSchemaIfNecessary = false});

        app.UseHangfireServer();
        app.UseHangfireDashboard("/hangfire");

    }

what’s your Idea ?


#8

Didn’t work is too general and ambiguous – blank screen, exception, 404 error, etc, etc. Can you provide more information about this topic. You can also include the following method to see actual exceptions:

app.UseErrorPage();
//app.UseHangfireServer();
app.UseHangfireDashboard("/hangfire");

#9

I’ve checked these both URLs: http://localhost:8888 , http://localhost:8888/hangfire . and for both I just see the welcome page . And also I used app.UseErrorPage();, but nothing happened , Neither error nor exception

and if I comment //app.UseWelcomePage(); the error would be “This webpage is not available” for both URLs


#10

Can you create a GitHub repository for that or share full source code of your application via Google Drive, Dropbox, etc?


#11

Here it is the repository on GitHub.

Thank you for your patience and cooperation.


#12

Could you upload the project again to serve as an example. This thread seems important for anyone who is starting off for the first time.