title: add all the required services by calling 'IServiceCollection.AddHealthChecks'
body: <p>I am using ASP.NET Core 3, .NET Core 3.0.100, Visual Studio 2019 Community. I follow this guide <a href="https://docs.microsoft.com/en-us/aspnet/core/release-notes/aspnetcore-3.0?view=aspnetcore-3.0#health-checks" rel="noreferrer">https://docs.microsoft.com/en-us/aspnet/core/release-notes/aspnetcore-3.0?view=aspnetcore-3.0#health-checks</a></p>
  
  <p>In <code>Startup.cs</code>, I add <code>endpoints.MapHealthChecks("/health");</code></p>
  
  <pre class="lang-cs prettyprint-override"><code>        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
          {         
  
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
                  app.UseDatabaseErrorPage();
              }
              else
              {
                  app.UseExceptionHandler("/Error");
                  // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                  app.UseHsts();
              }
              app.UseHttpsRedirection();
              app.UseStaticFiles();
              app.UseRouting();
              app.UseAuthentication();
              app.UseAuthorization();
              app.UseEndpoints(endpoints =&gt;
              {
                  endpoints.MapControllers();
                  endpoints.MapRazorPages();
                  endpoints.MapBlazorHub();
                  endpoints.MapFallbackToPage("/_Host");
                  endpoints.MapHealthChecks("/health");
              });
          }
      }
  }
  </code></pre>
  
  <p>Error</p>
  
  <pre><code>System.InvalidOperationException
    HResult=0x80131509
    Message=Unable to find the required services. Please add all the required services by calling 'IServiceCollection.AddHealthChecks' inside the call to 'ConfigureServices(...)' in the application startup code.
    Source=Microsoft.AspNetCore.Diagnostics.HealthChecks
    StackTrace:
     at Microsoft.AspNetCore.Builder.HealthCheckEndpointRouteBuilderExtensions.MapHealthChecksCore(IEndpointRouteBuilder endpoints, String pattern, HealthCheckOptions options)
     at Microsoft.AspNetCore.Builder.HealthCheckEndpointRouteBuilderExtensions.MapHealthChecks(IEndpointRouteBuilder endpoints, String pattern)
     at foo.Startup.&lt;&gt;c.&lt;Configure&gt;b__5_0(IEndpointRouteBuilder endpoints) in C:\Users\donhuvy\Desktop\acc133b3\acc133blazor\Startup.cs:line 104
     at Microsoft.AspNetCore.Builder.EndpointRoutingApplicationBuilderExtensions.UseEndpoints(IApplicationBuilder builder, Action`1 configure)
     at foo.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env) in C:\Users\donhuvy\Desktop\acc133b3\acc133blazor\Startup.cs:line 98
     at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
     at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
     at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
     at Microsoft.AspNetCore.Hosting.ConfigureBuilder.&lt;&gt;c__DisplayClass4_0.&lt;Build&gt;b__0(IApplicationBuilder builder)
     at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.&lt;&gt;c__DisplayClass13_0.&lt;UseStartup&gt;b__2(IApplicationBuilder app)
     at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.&lt;&gt;c__DisplayClass0_0.&lt;Configure&gt;g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
     at Microsoft.AspNetCore.Server.IIS.Core.IISServerSetupFilter.&lt;&gt;c__DisplayClass2_0.&lt;Configure&gt;b__0(IApplicationBuilder app)
     at Microsoft.AspNetCore.HostFilteringStartupFilter.&lt;&gt;c__DisplayClass0_0.&lt;Configure&gt;b__0(IApplicationBuilder app)
     at Microsoft.AspNetCore.Hosting.GenericWebHostService.&lt;StartAsync&gt;d__31.MoveNext()
  </code></pre>
  
  <p>How to fix it?</p>