Hangfire .Net Core 404

时间:2018-06-27 01:19:14

标签: .net-core hangfire

我们正尝试将hangfire与.Net核心部署到linux盒中。我们能够在本地运行和查看Hangfire仪表板,以及其他页面(如退休,工作等)。但是,当我们部署代码时,我们看到的是仪表板,但是所有的CSS和JS以及链接都指向domain / hangfire /域名/应用程序名称/ hangfire。

public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider)
{
    IConfigurationService confiuration = (IConfigurationService)serviceProvider.GetService(typeof(IConfigurationService));
    app.Use((context, next) =>
    {
        var pathBase = context.Request.Headers["X-Forwarded-PathBase"];
        context.Request.PathBase = new PathString(pathBase);
        return next();
    });

    app.UseCors(builder =>
    builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials());

    if (!env.IsProduction())
    {
        app.UseDeveloperExceptionPage();
    }
    app.UseSwagger(c =>
    {
        c.PreSerializeFilters.Add((swaggerDoc, httpReq) => swaggerDoc.BasePath = Configuration["Swagger:BasePath"]);
    });

    app.UseSwaggerUI(c =>
    {
        c.SwaggerEndpoint(Configuration["Swagger:JSONLocation"], "My Scheduler API V1");
        c.DocExpansion(DocExpansion.None);
    });
    app.UseAuthentication();
    //app.UseMiddleware<BasicAuthMiddleware>(confiuration.ApplicationUri);
    app.UseBasicAuthentication(confiuration.ApplicationUri);

    var options = new DashboardOptions
    {
        Authorization = new[] { new HangfireAuthorizationFilter() }
    };
    app.UseHangfireDashboard("/hangfire", options);
    app.UseHangfireServer();

    SchedulerInitializer.InitializeScheduler(confiuration);

    app.UseMvc();
}

0 个答案:

没有答案