我正在编写将验证验证码的属性.为了正常工作,它需要知道秘密,我保留在设置中(秘密管理器工具).但是我不知道如何从属性类中读取配置.asp.net核心中的DI支持构造函数注入(并且不支持属性注入),因此这将产生编译错误:
public ValidateReCaptchaAttribute(IConfiguration configuration)
{
if (configuration == null)
{
throw new ArgumentNullException("configuration");
}
this.m_configuration = configuration;
}
Run Code Online (Sandbox Code Playgroud)
因为我装饰方法时[ValidateReCaptcha]
我无法传递配置
那么如何从属性类中的方法中读取config中的内容呢?