是的,这是可能的dynamiclly使用RedirectToIdentityProvider
改变回复URL。您可以参考下面的代码示例:
app.UseOpenIdConnectAuthentication(
new OpenIdConnectAuthenticationOptions
{
ClientId = clientId,
Authority = authority,
PostLogoutRedirectUri = postLogoutRedirectUri,
RedirectUri = postLogoutRedirectUri,
Notifications = new OpenIdConnectAuthenticationNotifications
{
AuthenticationFailed = context =>
{
context.HandleResponse();
context.Response.Redirect("/Error?message=" + context.Exception.Message);
return Task.FromResult(0);
},
RedirectToIdentityProvider=(context)=>
{
context.ProtocolMessage.RedirectUri = "";
return Task.FromResult(0);
}
}
});
但是,如果应用程序已经部署到Web服务器上,更改重定向URL到本地主机可能无法按你的预期,因为有对网络两种不同的应用程序服务器应用运行。
什么这意味着是,你会手动将重定向URI请求URI?听起来像是唯一的方法.. – juunas
谢谢你的回报,但我不明白为什么要更改Azure AD中的重定向URL。它不是自动的? – Vilela
您在Azure门户上注册应用程序的重定向URL与您在请求中传递的重定向URL之间有所不同。 Azure广告将根据门户上的值寄存器验证传递的重定向URL。如果该值被验证,则Azure AD会将此URL返回给客户端。如果问题没有解决,请随时通知我。 –