【发布时间】:2018-04-08 08:02:15
【问题描述】:
我有这个扩展
public static class ServiceCollectionExtensions
{
public static IServiceCollection MyExtension(this IServiceCollection serviceCollection)
{
...
}
}
我需要从这样的服务中获取信息:
services.AddAuthentication(options =>
{
options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(JwtBearerDefaults.AuthenticationScheme, options =>
{
var myService = <<HERE>>();
options.TokenValidationParameters = this.GetTokenValidationParameters(myService);
});
我该怎么做?
我尝试在var serviceProvider = services.BuildServiceProvider(); 之后获取ServiceProvider,然后我发送serviceProvider,但这不起作用..
【问题讨论】:
标签: c# dependency-injection asp.net-core asp.net-core-2.0