【发布时间】:2016-12-14 21:11:53
【问题描述】:
我正在尝试使用我的应用程序连接到 Azure Active Directory,但出现以下错误: 处理请求时发生未处理的异常。
异常:OpenIdConnectAuthenticationHandler:message.State 为空 或为空。地点不明
AggregateException:未处理的远程故障。 Microsoft.AspNetCore.Authentication.RemoteAuthenticationHandler`1.d__5.MoveNext()
我的 appsettings.json 文件如下所示:
"AzureAd": {
"ClientId": "<Application ID value from Azure Portal>",
"AadInstance": "https://login.microsoftonline.com/{0}",
"TenantId": "<tenant>.onmicrosoft.com",
"AuthCallback": "/"
}
在 Startup.cs 中
app.UseCookieAuthentication();
app.UseIdentity();
app.UseOpenIdConnectAuthentication(new OpenIdConnectOptions
{
ClientId = Configuration["AzureAd:ClientId"],
Authority = string.Format(Configuration["AzureAd:AadInstance"], Configuration["AzureAd:TenantId"]),
CallbackPath = Configuration["AzureAd:AuthCallback"]
});
我在我的项目中启用了 ssl,并添加了 Visual Studio 给我的 url 作为回复 URL。
之前,当我配置了错误的 URL 时,它会引导我进入 Microsoft 登录站点,该站点说该 URL 与任何已注册的 URL 都不匹配,所以我知道它至少有那么远。
我也应该说我在关注this post,但使用的是新门户。我无权访问经典门户。
我该如何解决这个错误?
感谢您的帮助。
【问题讨论】:
-
你解决了这个问题吗?
标签: c# azure asp.net-core asp.net-core-mvc azure-active-directory