我使用dot net core 1.1开发了一个Web应用程序 . 它已经工作正常,直到我更新到asp核心2.0 . 然后,当尝试使用该应用程序时,它会报告此错误:
InvalidOperationException:未指定authenticationScheme,并且未找到DefaultChallengeScheme .
在 Startup.cs
的 Configure
方法中,JwtBearerAuthentication的身份验证配置以前就像下面这样:
app.UseJwtBearerAuthentication(new JwtBearerOptions
{
AutomaticAuthenticate = true,
AutomaticChallenge = true,
TokenValidationParameters = tokenValidationParameters
});
面对这个错误后,我已经更新了这个:
app.UseJwtBearerAuthentication(new JwtBearerOptions
{
AutomaticAuthenticate = true,
AutomaticChallenge = true,
TokenValidationParameters = tokenValidationParameters,
AuthenticationScheme = JwtBearerDefaults.AuthenticationScheme
});
但仍然是错误消息仍然存在 . 我错误地找错了地方,或者我必须为身份验证系统添加其他配置吗?
1 回答
我刚刚关注这篇文章,一切都很完美 .
Migrating Authentication and Identity to ASP.NET Core 2.0
希望它有助于其他 .
TG .