首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Hangfire .net核心404仪表板

Hangfire .net核心404仪表板
EN

Stack Overflow用户
提问于 2022-06-02 12:41:34
回答 1查看 157关注 0票数 0

我正在尝试为位于Docker上的api服务器部署Hangfire仪表板。在本地,当我运行https://localhost:1234/hangfire时,页面会正确显示。然而,一旦它坐在码头上,出于某种原因,它只显示404。

这是我的startup.cs

代码语言:javascript
复制
public void Services(IServiceCollection services, string connstr)
{
    var mysqlOptions = new MySqlStorageOptions
    {
        TransactionIsolationLevel = IsolationLevel.ReadCommitted,
        QueuePollInterval = TimeSpan.FromSeconds(15),
        JobExpirationCheckInterval = TimeSpan.FromHours(1),
        CountersAggregateInterval = TimeSpan.FromMinutes(5),
        PrepareSchemaIfNecessary = true,
        DashboardJobListLimit = 50000,
        TransactionTimeout = TimeSpan.FromMinutes(1),
        //TablesPrefix = "Hangfire"
    };
    services.AddHangfire(x => {
        x.UseStorage(new MySqlStorage(connstr, mysqlOptions));
    });
    services.AddHangfireServer();
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
    if (env.IsDevelopment())
    {
        app.UseDeveloperExceptionPage();
    }
    else
    {
        app.UseExceptionHandler("/Error/500");
        app.UseHsts();
    }
    LoadConfigurationServices loadConfigurationServices = new LoadConfigurationServices();
    loadConfigurationServices.Configure(app, env);

    var staticFileCacheInSeconds = configuration[SDR_Core.ClassLibrary.Globals.ConfigurationGlobals.StaticFileCacheInSeconds];

    app.UseStaticFiles(new StaticFileOptions
    {
        OnPrepareResponse = ctx => {
            int durationInSeconds = Int32.Parse(staticFileCacheInSeconds);
            ctx.Context.Response.Headers[HeaderNames.CacheControl] =
                "public,max-age=" + durationInSeconds;
        }
    });

    var culture = configuration[SDR_Core.ClassLibrary.Globals.ConfigurationGlobals.Culture];
    LoadCultureServices loadCultureServices = new LoadCultureServices();
    loadCultureServices.Configure(culture);
    app.UseRouting();
    app.UseAuthentication();
    app.UseAuthorization();
    app.UseEndpoints((config) =>
    {
        config.MapControllerRoute(
            name: "areas",
            pattern: "{area:exists}/{Controller=Home}/{Action=Index}/{id?}");
        config.MapControllerRoute(
            name: "default",
            pattern: "{Controller=Home}/{Action=Index}/{id?}");
        config.MapRazorPages();
    });
    app.UseHangfireDashboard("/hangfire");
    app.UseCookiePolicy();
}

在码头,我的网址是http://localhost:1234/hangfire

EN

回答 1

Stack Overflow用户

发布于 2022-06-09 12:05:44

我在下面的提示中找到,我知道我们可以访问本地的仪表板页面。

默认情况下,授权配置所需的允许只对本地请求访问仪表板页面。为了给生产使用提供适当的权利,请参阅配置授权部分。

因此,您可以参考官方文章来实现它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72476462

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档