1
我们正在实施经过AAD认证的应用程序中的Html.AntiForgeryToken()
。登录工作正常,但当我们点击主页上的按钮时,它需要调用控制器操作。以下例外情况未能通知控制器操作。任何想法来解决这个问题?使用Azure AD认证时,防伪验证失败
错误:
[HttpAntiForgeryException (0x80004005): The provided anti-forgery token was meant for user "[email protected]", but the current user is "".]
HTML:
using (Html.BeginForm("ExternalLogin", "Account", new { ReturnUrl = Model.ReturnUrl })) {
@Html.AntiForgeryToken()
<div id="LoginList">
<p>
@foreach (AuthenticationDescription p in loginProviders) {
<md-button type="submit" class="btn facebook-theme-background" id="@p.AuthenticationType" name="provider" value="@p.AuthenticationType" title="Log in using your @p.Caption account">Login with @p.AuthenticationType</md-button>
}
</p>
</div>
}
服务器端:它甚至没有进入这个方法。当我评论ValidateAntiForgeryToken
然后它进入。
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult ExternalLogin(string provider, string returnUrl)
{
}
使用下面的两个属性进行身份验证:
<add key="Tenant" value="xyz.onmicrosoft.com" />
<add key="Audience" value="<guid>" />
欢迎来到堆栈溢出,请抽出时间通过[欢迎游览](https://stackoverflow.com/tour)了解你在这里的方式(并获得你的第一个徽章),阅读如何[创建一个最小,完整和可验证的示例](https://stackoverflow.com/help/mcve),并检查[如何提出好问题](https://stackoverflow.com/help/how-to-ask ),所以你增加了获得反馈和有用答案的机会。 – Valentun