我尝试使用我的应用程序连接到 Azure Active Directory,但收到此错误: 处理请求时发生未处理的异常。
Exception: OpenIdConnectAuthenticationHandler: message.State is null or empty. Unknown location
AggregateException: Unhandled remote failure. 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 ,但使用新门户。我无法访问经典门户。
如何解决此错误?
感谢您的帮助。
最佳答案
如果有人遇到此问题,请向 OnMessageReceived 添加事件处理程序以调试请求。不知何故,我偶然将redirect_url设置为/signin-oidc,并且该路径上的GET将具有空上下文。属性当然会导致此特定错误
关于c# - OpenIdConnectAuthenticationHandler : message. 状态为 null 或为空。连接到 Azure Active Directory 时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41152266/