Getting weird warning.
AsP0014: Suggest using top level route registrations
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.SetupHealthChecksEndpoints();
});
My HealthCheck is 'Healthy' whereas
HealthCheckUI is 'UnHealthy' Error Endpoint.
Pleae help to resolve.
HemapriyaPosted Jun 10, 2024, 5:28 AM
Thanks Tuhin Paul!
Unfortunately still the same error. I corrected and used at the top level but still no luck.
HemapriyaPosted Jun 10, 2024, 5:24 AM
Thanks Jithu!
Unfortunately still doesn't work ! Any help please.
builder.Services.AddHealthChecksUI(setupSettings: setup =>
{
setup.AddHealthCheckEndpoint("example_health_check", "/health-ui");
}).AddInMemoryStorage();
app.MapHealthChecksUI(healthChecks => healthChecks
.UIPath = "/health-ui");
Jithu ThomasPosted Jun 8, 2024, 5:44 AM
1. Update Route Registrations
The new preferred method is to register routes directly on the app object. Here's how to adjust your code:
2. Verify HealthCheckUI Configuration
If your health check endpoint is healthy but HealthCheckUI is reporting it as unhealthy, it could be a configuration issue. Make sure the HealthCheckUI is correctly configured to point to the health check endpoint.
3. Custom Health Check Response Writer
Ensure the custom response writer is correctly implemented:
Try this way, it will work....
Tuhin PaulPosted Jun 8, 2024, 5:07 AM
Check how you can modify your code to use route registrations:
builder.Services.AddControllers();andbuilder.Services.AddHealthChecks()are used to add the necessary services.Tuhin PaulPosted Jun 8, 2024, 5:05 AM
Are you're registering routes using
app.UseEndpoints .In minimal APIs (introduced in ASP.NET Core 6+), it's recommended to register routes directly at the top level of the application, like this:
app.UseEndpointscall.app.MapControllers();andapp.SetupHealthChecksEndpoints();directly under theappvariable.