我现在奋斗了3天,以弄清楚为什么在除本地主机之外的所有环境中看不到我的死机。当我执行localhost / hangfire时,我会看到仪表板。每当我访问mysite-test.com/hangfire或mysite-acc.com/hangfire时,我都会得到HTTP ERROR 401.
的尝试,但没有成功。甚至添加:
app.UseHangfireDashboard("/hangfire", new DashboardOptions()
{
AppPath = "tools",
Authorization = new[] { new MyAuthorizationFilter() }
});
然后
public class MyAuthorizationFilter : IDashboardAuthorizationFilter
{
public bool Authorize(DashboardContext context)
{
return true;
//var httpContext = context.GetHttpContext();
//Allow all authenticated users to see the Dashboard(potentially dangerous).
//return httpContext.User.Identity.IsAuthenticated;
}
}
这就是我现在拥有的:
#region Usings
using System;
using System.Configuration;
using Hangfire;
using Hangfire.Dashboard;
using Microsoft.Owin;
using Owin;
#endregion
[assembly: OwinStartup(typeof(Startup))]
namespace Web.Api.Internal
{
public class Startup
{
private static readonly LoggingRepository _logger;
static Startup()
{
if (ConfigurationManager.AppSettings["OfflineWithoutMongoDB"]?.ToUpper() != "TRUE")
{
_logger = LoggingRepositoryManager.LoggingRepository;
}
}
public void Configuration(IAppBuilder app)
{
_logger?.Info("Internal WebApi Service firing up");
var configurationProvider = new ConfigurationProvider();
if (ConfigurationManager.AppSettings["OfflineWithoutMongoDB"]?.ToUpper() != "TRUE")
{
var isHangfireAvailable = true;
// Init Hangfire
try
{
GlobalConfiguration.Configuration.UseSqlServerStorage("HangfireDB");
}
catch (Exception ex)
{
_logger.Error("Cannot connect to HangfireDB", ex);
isHangfireAvailable = false;
}
if (isHangfireAvailable)
{
app.UseHangfireDashboard("/hangfire", new DashboardOptions()
{
AppPath = "/internal/tools",
Authorization = new[] { new MyAuthorizationFilter() }
});
app.UseHangfireServer();
}
var communityFacade = new CommunityFacade();
if (isHangfireAvailable)
{
有人知道我接下来要看什么吗?也许有人遇到同样的问题?