C# 未处理的异常。System.ArgumentNullException:值不能为null。(参数名称或连接字符串)

C# 未处理的异常。System.ArgumentNullException:值不能为null。(参数名称或连接字符串),c#,iis,.net-core,hangfire,hangfire-sql,C#,Iis,.net Core,Hangfire,Hangfire Sql,我正在ASP.net核心应用程序中使用hangfire来运行一些后台任务。我正在使用IIS,我已将Hangfire配置如下: using Hangfire; namespace Whm.APIPortal { public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration;

我正在ASP.net核心应用程序中使用hangfire来运行一些后台任务。我正在使用IIS,我已将Hangfire配置如下:

using Hangfire;

namespace Whm.APIPortal
{
    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddHangfire(option =>
            {
                option.UseSqlServerStorage(Configuration.GetConnectionString("HangFireConnection"));
            });
            services.AddHangfireServer();
         }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            app.UseHangfireDashboard();

            app.UseHangfireServer();
         }
     }
}
下面是我的appsettings.json文件

{
  "Logging": {
    "LogLevel": {
      "Default": "Information",
      "Microsoft": "Warning",
      "Microsoft.Hosting.Lifetime": "Information"
    }
  },
  "ConnectionStrings": {
    "DefaultConnection": "Server=.\\SQLEXPRESS;Database=Whm;User Id=sa;Password=***;MultipleActiveResultSets=true",
    "HangFireConnection": "Server=.\\SQLEXPRESS;Database=WhmHangFire;User Id=sa;Password=***;"
  },
  "AllowedHosts": "*"
}
每当我尝试启动应用程序时,都会出现以下异常

Unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'nameOrConnectionString')
我已经在我的sql server上创建了数据库“WhmHangFire”

但我还是得到了同样的例外。有人能解释一下是什么导致了这个问题吗


谢谢

代码希望调用连接字符串:name或connectionstring我该怎么做?我需要做哪些更改才能使其工作?检查Hangfire文档并了解连接字符串要求。代码中的某个地方连接字符串名称错误。不确定变量“nameOrConnectionString”来自何处。您的SQL数据库的名称是什么?您可以使用SQL Server Management Studio进行连接吗?在SSMS登录窗口中,服务器名称是什么?登录时是否显示窗口凭据,或者是否使用用户名和密码?错误消息很明显,但我在代码中没有看到nameOrConnectionString。你能给我看看吗?这就是hangfire文档没有提到任何关于名称或连接字符串的内容。