gpt4 book ai didi

asp.net-core-3.1 - ASP.NET Core 3.1 - 运行状况检查 UI 不工作

转载 作者:行者123 更新时间:2023-12-04 09:53:18 34 4
gpt4 key购买 nike

我开发了一个带有自定义健康检查的 ASP.NET Core 3.1 MVC 应用程序。它工作正常,如下所示。

enter image description here

但是,UI 始终为空,因为/health-api 始终返回空数组。 enter image description here

enter image description here

它位于 ASP.NET 3.1 Core 应用程序中,位于 https://github.com/prawin2k/HealhCheckMVC/tree/master/HealhCheckMVC

.NET 核心版本 - 3.1 (MVC)健康检查版本 - 最新操作系统:Windows Server 2016其他:Visual Studio 2019

最佳答案

在我的例子中,健康检查 UI 本身没有启动和崩溃 .net core 3.1 Web API 应用程序。

错误信息:某些服务无法构建(验证服务描述符“ServiceType:HealthChecks.UI.Core.Notifications.IHealthCheckFailureNotifier Lifetime:Scoped ImplementationType:HealthChecks.UI.Core.Notifications.WebHookFailureNotifier”时出错:无法解析服务在尝试激活“HealthChecks.UI.Core.Notifications.WebHookFailureNotifier”时输入“HealthChecks.UI.Core.Data.HealthChecksDb”。)

修复:添加任何UI storage provider .在我的例子中,我选择了 AddInMemoryStorage()

Startup.cs

public void ConfigureServices(IServiceCollection services)
{
...

services.AddHealthChecks()
.AddDbContextCheck<PollDbContext>() //nuget: Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore
.AddApplicationInsightsPublisher(); //nuget: AspNetCore.HealthChecks.Publisher.ApplicationInsights

services.AddHealthChecksUI() //nuget: AspNetCore.HealthChecks.UI
.AddInMemoryStorage(); //nuget: AspNetCore.HealthChecks.UI.InMemory.Storage

...
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
...

app.UseHealthChecks("/healthcheck", new HealthCheckOptions
{
Predicate = _ => true,
ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse //nuget: AspNetCore.HealthChecks.UI.Client
});

//nuget: AspNetCore.HealthChecks.UI
app.UseHealthChecksUI(options =>
{
options.UIPath = "/healthchecks-ui";
options.ApiPath = "/health-ui-api";
});
...
}

appsettings.json

"HealthChecks-UI": {
"DisableMigrations": true,
"HealthChecks": [
{
"Name": "PollManager",
"Uri": "/healthcheck"
}
],
"Webhooks": [
{
"Name": "",
"Uri": "",
"Payload": "",
"RestoredPayload": ""
}
],
"EvaluationTimeOnSeconds": 10,
"MinimumSecondsBetweenFailureNotifications": 60,
"MaximumExecutionHistoriesPerEndpoint": 15
}

关于asp.net-core-3.1 - ASP.NET Core 3.1 - 运行状况检查 UI 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61981081/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com