我正在尝试使用.Net 5向web添加身份验证,但在创建令牌的方法中得到上面的错误。ClaimTypes.Name, user.Username)
// The underlined error is on the line below on the GetSectionSymmetricSecurityKey key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration.GetSection(tokenH
首先,我会从launchSettings.json信息(例如地址:端口)中读取我要公开端点的位置。然后,我使用另一个json (appSettings.json)来放置一些配置变量,例如,它可以是应用程序的名称,或者某些连接的规则。我尝试将IConfiguration添加到单例上下文中,然后将其用于服务中。>(Configuration);这是我的服务的构造函数:
public ExampleService(IConfigurationIconfi
在我的ASP.NET Core3.1项目中,我试图通过依赖注入服务容器从"appsettings.json“读取一个配置选项,就像解释的或一样。但是,每当我到达需要在“Configuration.GetSection”中将Configuration.GetSection添加到ConfigureServices()的程度时,就会出现错误:
CS0120An object reference is required for the non-static field, method, or prope